<template>
  <div class="container">
    <div class="content-wrapper">
      <!-- 主内容区 -->
      <div class="main-content">
        <!-- <div class="status-bar">
          <div class="current-status">
            <span v-if="isReadOnly">当前状态：查看信息</span>
            <span v-else>当前状态：编辑信息</span>
          </div>
          <div class="loading-overlay" v-if="isLoading">
            <i class="fa fa-spinner fa-spin"></i> 加载中...
          </div>
        </div> -->
        
        <!-- 表单区域 -->
        <div class="form-container">
          <el-tabs v-model="activeTab" @tab-click="handleTabClick">
            <el-tab-pane label="基本信息" name="basicInfo">
              <div class="form-section" id="personal-info">
                <div class="section-header">
                  <h2>个人信息</h2>
                  <div class="header-actions">
                    <el-button 
                      v-if="!isBasicInfoReadOnly" 
                      type="success" 
                      size="small" 
                      @click="handleSaveBasicInfo"
                      style="margin-left: 10px;"
                    >
                      保存
                    </el-button>
                    <el-button 
                      v-if="isBasicInfoReadOnly" 
                      type="primary" 
                      size="small" 
                      @click="handleEditBasicInfo"
                      style="margin-left: 10px;"
                    >
                      编辑
                    </el-button>
                  </div>
                </div>
                
                <div class="personal-info-container">
                  <!-- 照片区域 -->
                  <div class="photo-section" v-for="(field, key) in fieldGroups.basicInfo" :key="key" v-if="key === 'photoUrl'">
                    <template>
                      <div v-if="isBasicInfoReadOnly" class="readonly-value photo-container">
                        <div class="photo-preview" v-if="formData[key] || formData._photoPreview">
                          <img :src="formData[key] ? 'data:image/jpeg;base64,' + formData[key] : formData._photoPreview" alt="照片预览">
                        </div>
                        <div class="photo-placeholder" v-else>
                          <i class="el-icon-user-solid"></i>
                          <span>未上传照片</span>
                        </div>
                      </div>
                      <div v-else class="editable-value photo-container">
                        <div class="photo-upload-wrapper">
                          <div class="photo-preview" v-if="formData[key]">
                            <img :src="'data:image/jpeg;base64,' + formData[key]" alt="照片预览">
                            <div class="photo-overlay">
                              <i class="el-icon-camera"></i>
                              <span>更换照片</span>
                            </div>
                          </div>
                          <div class="photo-placeholder" v-else>
                            <i class="el-icon-plus"></i>
                            <span>上传照片</span>
                          </div>
                          <input 
                            :type="field.type || 'file'" 
                            :id="key" 
                            :accept="field.accept || 'image/*'" 
                            @change="handleFileUpload(key, $event)"
                            class="photo-input"
                          >
                        </div>
                        <div class="photo-requirements">
                          <div class="requirement-item">
                            <i class="el-icon-info"></i>
                            <span>请上传一寸免冠彩色照片</span>
                          </div>
                          <div class="requirement-item">
                            <i class="el-icon-picture"></i>
                            <span>建议尺寸 413×531 像素</span>
                          </div>
                          <div class="requirement-item">
                            <i class="el-icon-document"></i>
                            <span>文件大小不超过2MB</span>
                          </div>
                        </div>
                        <span class="error-message" v-if="formErrors[key]">{{ formErrors[key] }}</span>
                      </div>
                    </template>
                  </div>

                  <!-- 基本信息表单 -->
                  <div class="form-grid">
                    <div class="form-group" v-for="(field, key) in fieldGroups.basicInfo" :key="key">
                      <template v-if="key !== 'photoUrl'">
                        <label :for="key" class="required">{{ field.label }}</label>
                        <div v-if="isBasicInfoReadOnly" class="readonly-value">
                          <span v-if="!['isWorking', 'gender', 'isPublicOfficial', 'isAcademic', 'isDesignMaster', 'isSubsidy', 'isSpecial'].includes(key)">
                            {{ getDisplayValue(key, formData[key]) }}
                          </span>
                          <span v-else>
                            {{ formData[key] || '未选择' }}
                          </span>
                        </div>
                        <div v-else class="editable-value">
                          <template v-if="key === 'gender' || key === 'politicalStatus' || key === 'education' || key === 'title' || key === 'nativePlace'">
                            <template v-if="key === 'nativePlace'">
                              <el-cascader
                                v-model="formData[key]"
                                :options="citys"
                                :props="{ expandTrigger: 'hover' }"
                                style="width: 100%"
                                placeholder="请选择籍贯"
                              ></el-cascader>
                            </template>
                            <template v-else>
                              <el-select v-model="formData[key]" placeholder="请选择" style="width: 100%">
                                <el-option
                                  v-for="option in getOptionsForField(key)"
                                  :key="option.value"
                                  :label="option.label"
                                  :value="option.value"
                                >
                                </el-option>
                              </el-select>
                            </template>
                          </template>
                          <template v-else-if="key === 'isPublicOfficial' || key === 'isAcademic' || key === 'isDesignMaster' || key === 'isSubsidy' || key === 'isSpecial'">
                            <select :id="key" v-model="formData[key]">
                              <option value="">请选择</option>
                              <option v-for="(optionValue, optionLabel) in field.options" :value="optionValue" :key="optionValue">
                                {{ optionLabel }}
                              </option>
                            </select>
                          </template>
                          <template v-else-if="key === 'ethnicity'">
                            <el-input v-model="formData[key]" placeholder="请输入民族"></el-input>
                          </template>
                          <template v-else>
                            <input :type="field.type || 'text'" :id="key" v-model="formData[key]" :placeholder="field.placeholder || '请输入'">
                          </template>
                          <span class="error-message" v-if="formErrors[key]">{{ formErrors[key] }}</span>
                        </div>
                      </template>
                    </div>
                  </div>
                </div>
              </div>
              
              <div class="form-section" id="major-info">
                <div class="section-header">
                  <h2>专业</h2>
                </div>
                
                                  <div class="form-grid">
                  <div class="form-group">
                    <label class="required">第一专业(主专业)</label>
                    <div v-if="isBasicInfoReadOnly" class="readonly-value">
                      <span>{{ getDisplayValue('primaryMajor', formData.primaryMajor) }}</span>
                    </div>
                    <div v-else class="editable-value">
                      <el-cascader
                        v-model="formData.primaryMajor"
                        :options="options1"
                        style="width: 100%"
                        @change="handleMajorChange(0)"
                        placeholder="请选择主专业"
                      ></el-cascader>
                      <span class="error-message" v-if="showMajorError[0]">专业出现重复</span>
                    </div>
                  </div>

                  <div class="form-group">
                    <label class="required">第二专业</label>
                    <div v-if="isBasicInfoReadOnly" class="readonly-value">
                      <span>{{ getDisplayValue('secondMajor', formData.secondMajor) }}</span>
                    </div>
                    <div v-else class="editable-value">
                      <el-cascader
                        v-model="formData.secondMajor"
                        :options="options"
                        style="width: 100%"
                        @change="handleMajorChange(1)"
                        placeholder="请选择专业"
                      ></el-cascader>
                      <span class="error-message" v-if="showMajorError[1]">专业出现重复</span>
                    </div>
                  </div>

                  <div class="form-group">
                    <label>第三专业</label>
                    <div v-if="isBasicInfoReadOnly" class="readonly-value">
                      <span>{{ getDisplayValue('thirdMajor', formData.thirdMajor) }}</span>
                    </div>
                    <div v-else class="editable-value">
                      <el-cascader
                        v-model="formData.thirdMajor"
                        :options="options"
                        style="width: 100%"
                        @change="handleMajorChange(2)"
                        placeholder="请选择专业"
                      ></el-cascader>
                      <span class="error-message" v-if="showMajorError[2]">专业出现重复</span>
                    </div>
                  </div>

                  <div class="form-group">
                    <label>第四专业</label>
                    <div v-if="isBasicInfoReadOnly" class="readonly-value">
                      <span>{{ getDisplayValue('fourthMajor', formData.fourthMajor) }}</span>
                    </div>
                    <div v-else class="editable-value">
                      <el-cascader
                        v-model="formData.fourthMajor"
                        :options="options"
                        style="width: 100%"
                        @change="handleMajorChange(3)"
                        placeholder="请选择专业"
                      ></el-cascader>
                      <span class="error-message" v-if="showMajorError[3]">专业出现重复</span>
                    </div>
                  </div>

                  <div class="form-group">
                    <label>第五专业</label>
                    <div v-if="isBasicInfoReadOnly" class="readonly-value">
                      <span>{{ getDisplayValue('fifthMajor', formData.fifthMajor) }}</span>
                    </div>
                    <div v-else class="editable-value">
                      <el-cascader
                        v-model="formData.fifthMajor"
                        :options="options"
                        style="width: 100%"
                        @change="handleMajorChange(4)"
                        placeholder="请选择专业"
                      ></el-cascader>
                      <span class="error-message" v-if="showMajorError[4]">专业出现重复</span>
                    </div>
                  </div>

                  <div class="form-group">
                    <label class="required">从事水利相关领域工作时间(年)</label>
                    <div v-if="isBasicInfoReadOnly" class="readonly-value">
                      <span>{{ formData.workTime || '-' }}</span>
                    </div>
                    <div v-else class="editable-value">
                      <el-input 
                        v-model="formData.workTime" 
                        type="number"
                        style="width: 100%"
                        placeholder="请输入工作年限"
                      ></el-input>
                    </div>
                  </div>
                </div>
              </div>
              
              <div class="form-section" id="other-info">
                  <div class="section-header">
                    <h2>其他</h2>
                  </div>  
                  <div class="form-grid">
                    <!-- 其他信息表单内容 -->
                    <div class="form-group" v-for="(field, key) in fieldGroups.otherInfo" :key="key">
                      <label :for="key" class="required">{{ field.label }}</label>
                      <div v-if="isBasicInfoReadOnly" class="readonly-value">
                        <span v-if="key === 'registeredQualification'">
                          {{ formData[key] || '无' }}
                        </span>
                        <span v-else>
                          {{ formData[key] === true ? '是' : '否' }}
                        </span>
                      </div>
                      <div v-else class="editable-value">
                        <template v-if="key === 'registeredQualification'">
                          <div class="input-with-hint">
                            <input :type="field.type" :id="key" v-model="formData[key]" :placeholder="field.placeholder">
                          </div>
                        </template>
                        <template v-else>
                          <div class="radio-group">
                            <label class="radio-label">
                              <input type="radio" :name="key" :value="true" v-model="formData[key]"> 是
                            </label>
                            <label class="radio-label">
                              <input type="radio" :name="key" :value="false" v-model="formData[key]"> 否
                            </label>
                          </div>
                        </template>
                        <span class="error-message" v-if="formErrors[key]">{{ formErrors[key] }}</span>
                      </div>
                    </div>
                  </div>
                </div>
              </el-tab-pane>
            
            <el-tab-pane label="工作履历" name="workExperience">
              <div class="form-section" id="work-experience">
                <div class="section-header">
                  <h2>主要工作经历</h2>
                  <div class="header-actions">
                    <el-button 
                      v-if="!isWorkExperienceReadOnly" 
                      type="primary" 
                      size="small" 
                      @click="handleAddWorkExperience"
                    >
                      添加工作经历
                    </el-button>
                    <el-button 
                      v-if="isWorkExperienceReadOnly" 
                      type="primary" 
                      size="small" 
                      @click="handleEditWorkExperienceInfo"
                      style="margin-left: 10px;"
                    >
                      编辑
                    </el-button>
                    <el-button 
                      v-if="!isWorkExperienceReadOnly" 
                      type="success" 
                      size="small" 
                      @click="handleSaveWorkExperienceInfo"
                      style="margin-left: 10px;"
                    >
                      保存
                    </el-button>
                  </div>
                </div>
                <el-table 
                  :data="workExperienceList" 
                  border 
                  style="margin-bottom: 20px;"
                  v-loading="loading"
                >
                  <el-table-column type="index" label="序号" width="50" align="center"></el-table-column>
                  <el-table-column label="工作单位" prop="orgName" min-width="150" show-overflow-tooltip>
                    <template slot-scope="scope">
                      <span v-if="editingIndex === scope.$index">
                        <el-input v-model="scope.row.orgName" placeholder="请输入工作单位"></el-input>
                      </span>
                      <span v-else>{{ scope.row.orgName || '-' }}</span>
                    </template>
                  </el-table-column>
                  <el-table-column label="开始时间" prop="startDate" width="120" align="center">
                    <template slot-scope="scope">
                      <span v-if="editingIndex === scope.$index">
                        <el-date-picker
                          v-model="scope.row.startDate"
                          type="date"
                          placeholder="选择日期"
                          format="yyyy-MM-dd"
                          value-format="yyyy-MM-dd"
                          style="width: 100%"
                        ></el-date-picker>
                      </span>
                      <span v-else>{{ scope.row.startDate || '-' }}</span>
                    </template>
                  </el-table-column>
                  <el-table-column label="结束时间" prop="endDate" width="120" align="center">
                    <template slot-scope="scope">
                      <span v-if="editingIndex === scope.$index">
                        <el-date-picker
                          v-model="scope.row.endDate"
                          type="date"
                          placeholder="选择日期"
                          format="yyyy-MM-dd"
                          value-format="yyyy-MM-dd"
                          style="width: 100%"
                        ></el-date-picker>
                      </span>
                      <span v-else>{{ scope.row.endDate === 'null' || !scope.row.endDate ? '至今' : scope.row.endDate }}</span>
                    </template>
                  </el-table-column>
                  <el-table-column label="职称" prop="jobTitle" width="150" align="center" show-overflow-tooltip>
                    <template slot-scope="scope">
                      <span v-if="editingIndex === scope.$index">
                        <el-input v-model="scope.row.jobTitle" placeholder="请输入职称"></el-input>
                      </span>
                      <span v-else>{{ scope.row.jobTitle || '-' }}</span>
                    </template>
                  </el-table-column>
                  <el-table-column label="职务" prop="jobDuty" min-width="150" show-overflow-tooltip>
                    <template slot-scope="scope">
                      <span v-if="editingIndex === scope.$index">
                        <el-input v-model="scope.row.jobDuty" placeholder="请输入职务"></el-input>
                      </span>
                      <span v-else>{{ scope.row.jobDuty === '无' ? '-' : (scope.row.jobDuty || '-') }}</span>
                    </template>
                  </el-table-column>
                  <el-table-column label="操作" width="150" align="center" v-if="!isWorkExperienceReadOnly">
                    <template slot-scope="scope">
                      <el-button
                        v-if="editingIndex === scope.$index"
                        type="success"
                        size="mini"
                        @click="handleSaveWorkExperience(scope.$index, scope.row)"
                      >
                        保存
                      </el-button>
                      <el-button
                        v-if="editingIndex === scope.$index"
                        type="info"
                        size="mini"
                        @click="handleCancelEdit"
                      >
                        取消
                      </el-button>
                      <el-button
                        v-if="editingIndex !== scope.$index"
                        type="primary"
                        size="mini"
                        @click="handleEditWorkExperience(scope.$index, scope.row)"
                      >
                        编辑
                      </el-button>
                      <el-button
                        v-if="editingIndex !== scope.$index"
                        type="danger"
                        size="mini"
                        @click="handleDeleteWorkExperience(scope.$index)"
                      >
                        删除
                      </el-button>
                    </template>
                  </el-table-column>
                </el-table>

                <div class="section-header" style="margin-top: 20px;">
                  <h2>社会兼、聘职情况</h2>
                  <div class="header-actions">
                    <el-button 
                      v-if="isSocialExperienceReadOnly" 
                      type="primary" 
                      size="small" 
                      @click="handleEditSocialExperienceInfo"
                      style="margin-left: 10px;"
                    >
                      编辑
                    </el-button>
                    <template v-else>
                      <el-button 
                        type="primary" 
                        size="small" 
                        @click="handleAddSocialExperience"
                      >
                        添加兼职经历
                      </el-button>
                      <el-button 
                        type="success" 
                        size="small" 
                        @click="handleSaveSocialExperienceInfo"
                        style="margin-left: 10px;"
                      >
                        保存
                      </el-button>
                      <el-button 
                        type="info" 
                        size="small" 
                        @click="handleCancelSocialExperienceInfo"
                        style="margin-left: 10px;"
                      >
                        取消
                      </el-button>
                    </template>
                  </div>
                </div>
                <el-table 
                  :data="socialExperienceList" 
                  border 
                  style="margin-bottom: 20px; width: 100%"
                  v-loading="loading"
                >
                  <el-table-column type="index" label="序号" width="60" align="center"></el-table-column>
                  <el-table-column 
                    label="兼职单位" 
                    prop="orgName"
                    min-width="150"
                    show-overflow-tooltip
                  >
                    <template slot-scope="scope">
                      <span v-if="socialEditingIndex === scope.$index">
                        <el-input v-model="scope.row.orgName" placeholder="请输入兼职单位"></el-input>
                      </span>
                      <span v-else>{{ scope.row.orgName || '-' }}</span>
                    </template>
                  </el-table-column>
                  <el-table-column 
                    label="开始时间" 
                    prop="startDate" 
                    width="120" 
                    align="center"
                  >
                    <template slot-scope="scope">
                      <span v-if="socialEditingIndex === scope.$index">
                        <el-date-picker
                          v-model="scope.row.startDate"
                          type="date"
                          placeholder="选择日期"
                          format="yyyy-MM-dd"
                          value-format="yyyy-MM-dd"
                          style="width: 100%"
                        ></el-date-picker>
                      </span>
                      <span v-else>{{ scope.row.startDate || '-' }}</span>
                    </template>
                  </el-table-column>
                  <el-table-column 
                    label="结束时间" 
                    prop="endDate" 
                    width="120" 
                    align="center"
                  >
                    <template slot-scope="scope">
                      <span v-if="socialEditingIndex === scope.$index">
                        <el-date-picker
                          v-model="scope.row.endDate"
                          type="date"
                          placeholder="选择日期"
                          format="yyyy-MM-dd"
                          value-format="yyyy-MM-dd"
                          style="width: 100%"
                        ></el-date-picker>
                      </span>
                      <span v-else>{{ scope.row.endDate === 'null' || !scope.row.endDate ? '至今' : scope.row.endDate }}</span>
                    </template>
                  </el-table-column>
                  <el-table-column 
                    label="兼职身份" 
                    prop="role" 
                    min-width="120"
                    show-overflow-tooltip
                  >
                    <template slot-scope="scope">
                      <span v-if="socialEditingIndex === scope.$index">
                        <el-input v-model="scope.row.role" placeholder="请输入兼职身份"></el-input>
                      </span>
                      <span v-else>{{ scope.row.role === '无' ? '-' : (scope.row.role || '-') }}</span>
                    </template>
                  </el-table-column>
                  <el-table-column label="操作" width="150" align="center" v-if="!isSocialExperienceReadOnly">
                    <template slot-scope="scope">
                      <el-button
                        v-if="socialEditingIndex === scope.$index"
                        type="success"
                        size="mini"
                        @click="handleSaveSocialExperience(scope.$index, scope.row)"
                      >
                        保存
                      </el-button>
                      <el-button
                        v-if="socialEditingIndex === scope.$index"
                        type="info"
                        size="mini"
                        @click="handleCancelSocialEdit"
                      >
                        取消
                      </el-button>
                      <el-button
                        v-if="socialEditingIndex !== scope.$index"
                        type="primary"
                        size="mini"
                        @click="handleEditSocialExperience(scope.$index, scope.row)"
                      >
                        编辑
                      </el-button>
                      <el-button
                        v-if="socialEditingIndex !== scope.$index"
                        type="danger"
                        size="mini"
                        @click="handleDeleteSocialExperience(scope.$index)"
                      >
                        删除
                      </el-button>
                    </template>
                  </el-table-column>
                </el-table>

                <div class="section-header" style="margin-top: 20px;">
                  <h2>其他</h2>
                  <div class="header-actions">
                    <el-button 
                      v-if="isOtherInfoReadOnly" 
                      type="primary" 
                      size="small" 
                      @click="handleEditOtherInfo"
                      style="margin-left: 10px;"
                    >
                      编辑
                    </el-button>
                    <el-button 
                      v-if="!isOtherInfoReadOnly" 
                      type="success" 
                      size="small" 
                      @click="handleSaveOtherInfo"
                      style="margin-left: 10px;"
                    >
                      保存
                    </el-button>
                    <el-button 
                      v-if="!isOtherInfoReadOnly" 
                      type="info" 
                      size="small" 
                      @click="handleCancelOtherInfo"
                      style="margin-left: 10px;"
                    >
                      取消
                    </el-button>
                  </div>
                </div> 
                <div class="form-group">
                  <label>本人专业领域研究及成果:</label>
                  <el-input 
                    type="textarea" 
                    :rows="4" 
                    v-model="otherInfoForm.researchResults"
                    :disabled="isOtherInfoReadOnly"
                    resize="none"
                    placeholder="请输入研究成果"
                    class="other-info-textarea"
                  ></el-input>
                </div>
                <div class="form-group" style="margin-top: 16px;">
                  <label>本人参加过何种项目咨询、审查、论证等事项:</label>
                  <el-input 
                    type="textarea" 
                    :rows="4" 
                    v-model="otherInfoForm.projectConsultation"
                    :disabled="isOtherInfoReadOnly"
                    resize="none"
                    placeholder="请输入项目事项"
                    class="other-info-textarea"
                  ></el-input>
                </div>
              </div>
            </el-tab-pane>
            
            <el-tab-pane label="附件上传" name="attachmentUpload">
              <div class="form-section" id="attachment-upload">
                <div class="section-header">
                  <h2>附件上传</h2>
                  <div class="header-actions">
                    <el-button 
                      v-if="isAttachmentReadOnly" 
                      type="primary" 
                      size="small" 
                      @click="handleEditAttachmentInfo"
                      style="margin-left: 10px;"
                    >
                      编辑
                    </el-button>
                    <el-button 
                      v-if="!isAttachmentReadOnly" 
                      type="success" 
                      size="small" 
                      @click="handleSaveAttachmentInfo"
                      style="margin-left: 10px;"
                    >
                      保存
                    </el-button>
                  </div>
                </div>
                <div class="section-header">
                  <!-- <h2>附件上传</h2> -->
                </div>
                <div class="attachments-container">
                  <div class="attachment-item" v-for="(field, key) in fieldGroups.attachmentUpload" :key="key">
                    <div class="attachment-label">
                      <label :for="key" class="required">{{ field.label }}</label>
                    </div>
                    
                    <div v-if="isAttachmentReadOnly" class="readonly-attachment">
                      <div class="attachment-card" v-if="attachmentFiles[getAttachmentType(key)].fileId" @click="downloadFile(getAttachmentType(key))">
                        <div class="attachment-icon">
                          <i :class="getFileIcon(attachmentFiles[getAttachmentType(key)].fileName)"></i>
                        </div>
                        <div class="attachment-info">
                          <span class="attachment-name">
                            <template v-if="key === 'idCardFrontUrl'">
                              {{ formData.name || '未知专家' }}的身份证
                            </template>
                            <template v-else-if="key === 'idCardBackUrl'">
                              {{ formData.name || '未知专家' }}的最高学历(学位)证书及技术职称
                            </template>
                            <template v-else-if="key === 'degreeCertificateUrl'">
                              {{ formData.name || '未知专家' }}的职业资格证书
                            </template>
                            <template v-else-if="key === 'professionalCertificateUrl'">
                              {{ formData.name || '未知专家' }}的研究成果及工作成就材料
                            </template>
                            <template v-else-if="key === 'otherDocumentsUrl'">
                              {{ formData.name || '未知专家' }}的专家入库申请表
                            </template>
                            <template v-else>
                              {{ attachmentFiles[getAttachmentType(key)].fileName }}
                            </template>
                          </span>
                          <span class="attachment-action">
                            <i class="el-icon-download"></i>
                            点击下载
                          </span>
                        </div>
                      </div>
                      <div class="attachment-empty" v-else>
                        <i class="el-icon-document"></i>
                        <span>
                          <template v-if="key === 'idCardFrontUrl'">
                            {{ formData.name || '未知专家' }}的身份证未上传
                          </template>
                          <template v-else-if="key === 'idCardBackUrl'">
                            {{ formData.name || '未知专家' }}的最高学历(学位)证书及技术职称未上传
                          </template>
                          <template v-else-if="key === 'degreeCertificateUrl'">
                            {{ formData.name || '未知专家' }}的职业资格证书未上传
                          </template>
                          <template v-else-if="key === 'professionalCertificateUrl'">
                            {{ formData.name || '未知专家' }}的研究成果及工作成就材料未上传
                          </template>
                          <template v-else-if="key === 'otherDocumentsUrl'">
                            {{ formData.name || '未知专家' }}的专家入库申请表未上传
                          </template>
                          <template v-else>
                            {{ attachmentFiles[getAttachmentType(key)].fileName }}
                          </template>
                        </span>
                      </div>
                    </div>
                    
                    <div v-else class="editable-attachment">
                      <div class="attachment-card" v-if="attachmentFiles[getAttachmentType(key)].fileId">
                        <div class="attachment-icon">
                          <i :class="getFileIcon(attachmentFiles[getAttachmentType(key)].fileName)"></i>
                        </div>
                        <div class="attachment-info">
                          <span class="attachment-name">
                            <template v-if="key === 'idCardFrontUrl'">
                              {{ formData.name || '未知专家' }}的身份证
                            </template>
                            <template v-else-if="key === 'idCardBackUrl'">
                              {{ formData.name || '未知专家' }}的最高学历(学位)证书及技术职称
                            </template>
                            <template v-else-if="key === 'degreeCertificateUrl'">
                              {{ formData.name || '未知专家' }}的职业资格证书
                            </template>
                            <template v-else-if="key === 'professionalCertificateUrl'">
                              {{ formData.name || '未知专家' }}的研究成果及工作成就材料
                            </template>
                            <template v-else-if="key === 'otherDocumentsUrl'">
                              {{ formData.name || '未知专家' }}的专家入库申请表
                            </template>
                            <template v-else>
                              {{ attachmentFiles[getAttachmentType(key)].fileName }}
                            </template>
                          </span>
                          <div class="attachment-actions">
                            <span class="action-download" @click.stop="downloadFile(getAttachmentType(key))">
                              <i class="el-icon-download"></i>
                              下载
                            </span>
                            <span class="action-delete" @click.stop="deleteFile(getAttachmentType(key))">
                              <i class="el-icon-delete"></i>
                              删除
                            </span>
                          </div>
                        </div>
                      </div>
                      
                      <div class="attachment-upload" v-else>
                        <input 
                          :type="field.type || 'file'" 
                          :id="key" 
                          accept=".pdf" 
                          @change="handleAttachmentUpload(getAttachmentType(key), $event)"
                          class="attachment-input"
                        >
                        <div class="upload-area">
                          <i class="el-icon-upload"></i>
                          <div class="upload-text">
                            <span>点击上传或拖拽文件到此处</span>
                            <p class="upload-tip">支持 PDF、PNG、JPG 格式，文件大小不超过10MB</p>
                          </div>
                        </div>
                      </div>
                      <span class="error-message" v-if="formErrors[key]">{{ formErrors[key] }}</span>
                    </div>
                  </div>
                </div>
              </div>
            </el-tab-pane>

            <!-- 其他信息页面 -->
            <!-- <el-tab-pane label="其他信息" name="otherInfo">
              <div class="form-section" id="other-info">
                <div class="section-header">
                  <h2>其他信息</h2>
                  <div class="header-actions">
                    <el-button 
                      v-if="isOtherInfoReadOnly" 
                      type="primary" 
                      size="small" 
                      @click="editOtherInfo"
                      style="margin-left: 10px;"
                    >
                      编辑
                    </el-button>
                    <template v-else>
                      <el-button 
                        type="success" 
                        size="small" 
                        @click="saveOtherInfo"
                        style="margin-left: 10px;"
                      >
                        保存
                      </el-button>
                      <el-button 
                        type="info" 
                        size="small" 
                        @click="cancelOtherInfo"
                        style="margin-left: 10px;"
                      >
                        取消
                      </el-button>
                    </template>
                  </div>
                </div>
                
                <el-form
                  :model="otherInfoForm"
                  label-width="120px"
                  class="other-info-form"
                  :disabled="isOtherInfoReadOnly"
                >
                  <el-form-item label="研究成果">
                    <el-input
                      type="textarea"
                      v-model="otherInfoForm.researchResults"
                      :rows="4"
                      placeholder="请输入研究成果"
                    ></el-input>
                  </el-form-item>
                  <el-form-item label="项目咨询">
                    <el-input
                      type="textarea"
                      v-model="otherInfoForm.projectConsultation"
                      :rows="4"
                      placeholder="请输入项目咨询经历"
                    ></el-input>
                  </el-form-item>
                </el-form>
              </div>
            </el-tab-pane> -->
            
            <!-- 信息审核页面 -->
            <!-- <el-tab-pane label="信息审核" name="informationReview">
              <div class="form-section" id="information-review">
                <div class="section-header">
                  <h2>信息审核</h2> 
                </div> 
                <div class="section-content">
                  <el-input
                    type="textarea"
                    :rows="15"
                    disabled
                    style="height: 300px" 
                  ></el-input>
                </div>                             
              </div>
            </el-tab-pane> -->
          </el-tabs>
        </div>
      </div>
    </div>

    <!-- 文件预览弹窗 -->
    <el-dialog
      :visible.sync="previewDialogVisible"
      :title="previewFileName"
      width="70%"
      class="preview-dialog"
      @close="closePreview"
    >
      <div class="preview-container">
        <!-- PDF预览 -->
        <iframe
          v-if="isPdfFile"
          :src="previewUrl"
          class="pdf-preview"
        ></iframe>
        <!-- 图片预览 -->
        <img
          v-else-if="isImageFile"
          :src="previewUrl"
          class="image-preview"
          alt="预览图片"
        >
        <!-- 不支持的文件格式 -->
        <div v-else class="unsupported-preview">
          <i class="el-icon-warning"></i>
          <p>该文件格式暂不支持预览</p>
        </div>
      </div>
    </el-dialog>
  </div>
</template>

<script>
import { getExpertBasicInfo, getExpertAttach, getFileInfo, addOrUpdateExpert, addOrUpdateWorkExperience, addOrUpdateSocialPart, addOrUpdateOtherInfo, uploadExpertAttach, uploadImage, downloadFile } from '@/api/table'
import { getAttachmentsByExpertId } from '@/api/new'
import { pickerOptions } from './config';
// import role from '../../api/system/role';

export default {
  name: 'ExpertShow',
  props: {
    row: {
      type: Object,
      required: true,
      default: () => ({})
    }
  },
      data() {
      return {
        activeTab: 'basicInfo',
        hasLoadedAttachments: false,
        isBasicInfoReadOnly: true,
        isWorkExperienceReadOnly: true,
        isAttachmentReadOnly: true,
        isLoading: false,
        isAdding: false,
        loading: false,
        formData: {
        photoUrl: '',
        name: '',
        gender: '',
        ethnicity: '',
        birthDate: '',
        idCard: '',
        nativePlace: '',
        politicalStatus: '',
        healthStatus: '',
        education: '',
        graduateSchool: '',
        workUnit: '',
        job: '',
        title: '',
        isPublicOfficial: '',
        phone: '',
        email: '',
        bankName: '',
        bankAccount: '',
        primaryMajor: '',
        secondMajor: '',
        thirdMajor: '',
        fourthMajor: '',
        fifthMajor: '',
        workTime: '',
        isAcademic: '',
        isDesignMaster: '',
        isSubsidy: '',
        isSpecial: '',
        registeredQualification: '',
        auditStatus: '',
        auditOpinion: '',
        changeCounts: 0,
        joinMeeting: 0,
        attachments: {
          idCard: null,
          certificate: null,
          qualification: null,
          supportMater: null,
          applicationForm: null
        },
        uploadFiles: {
          idCard: null,
          certificate: null,
          qualification: null,
          supportMater: null,
          applicationForm: null
        }
      },
      workExperienceList: [],
      socialExperienceList: [],
      researchResults: '',
      projectMatters: '',
      editingIndex: -1,
      formErrors: {},
      databaseValue: '', // 信息审核页显示的内容
      // 表单字段配置
      fieldGroups: {
        basicInfo: {
          photoUrl: {
            label: '照片',
            type: 'file',
            accept: 'image/*'
          },
          name: {
            label: '姓名',
            type: 'text',
            required: true
          },
          gender: { label: '性别', type: 'select', options: { '男': '男', '女': '女' } },
                        ethnicity: { label: '民族', type: 'text', placeholder: '请输入民族' },
          birthDate: { label: '出生年月', type: 'date' },
          idCard: { label: '身份证号', type: 'text' },
          nativePlace: { label: '籍贯', type: 'text' },
          politicalStatus: { label: '政治面貌', type: 'text', placeholder: '请输入政治面貌' },
          healthStatus: { label: '健康状况', type: 'text' },
          education: { label: '学历', type: 'text' },
          graduateSchool: { label: '毕业院校', type: 'text' },
          workUnit: { label: '工作单位', type: 'text' },
          job: { label: '职务', type: 'text' },
          title: { label: '职称', type: 'text' },
          isPublicOfficial: { label: '是否为在职人员', type: 'select', options: { '是': '是', '否': '否' } },
          phone: { label: '手机', type: 'text' },
          email: { label: '邮箱', type: 'email' },
          bankName: { label: '银行名称', type: 'text' },
          bankAccount: { label: '银行卡号', type: 'text' }
        },
        majorInfo: {
          primaryMajor: { label: '第一专业（主专业）', type: 'text' },
          secondMajor: { label: '第二专业', type: 'text' },
          thirdMajor: { label: '第三专业', type: 'text' },
          fourthMajor: { label: '第四专业', type: 'text' },
          fifthMajor: { label: '第五专业', type: 'text' },
          workTime: { label: '从事水利相关领域工作时间', type: 'number' }
        },
        otherInfo: {
          isAcademic: { label: '是否为院士', type: 'select', options: { '是': '是', '否': '否' } },
          isDesignMaster: { label: '是否为全国或省级工程勘察设计大师（水利）', type: 'select', options: { '是': '是', '否': '否' } },
          isSubsidy: { label: '是否为享受国务院政府特殊津贴的专家', type: 'select', options: { '是': '是', '否': '否' } },
          isSpecial: { label: '是否为人才紧缺的特殊专业、特殊领域技术人才', type: 'select', options: { '是': '是', '否': '否' } },
          registeredQualification: { label: '国家注册执业资格', type: 'text', placeholder: '请输入国家注册执业资格' }
        },
        workExperience: {
          orgName: { label: '工作单位', type: 'text', placeholder: '请输入工作单位' },
          startDate: { label: '开始时间', type: 'date' },
          endDate: { label: '结束时间', type: 'date' },
          jobTitle: { label: '职称', type: 'text', placeholder: '请输入职称' },
          jobDuty: { label: '职务', type: 'text', placeholder: '请输入职务' },
          jobDescription: { label: '工作描述', type: 'text', placeholder: '请描述您的工作职责和成就' }
        },
        attachmentUpload: {
          idCardFrontUrl: { label: '身份证', type: 'file', accept: 'image/*' },
          idCardBackUrl: { label: '最高学历(学位)证书及技术职称', type: 'file', accept: 'image/*' },
          degreeCertificateUrl: { label: '职业资格', type: 'file', accept: 'image/*' },
          professionalCertificateUrl: { label: '个人研究成果、工作成就、参与评审项目等相关证明查看案例材料', type: 'file', accept: 'image/*' },
          otherDocumentsUrl: { label: '陕西省水利厅专家入库申请表(签字盖章)', type: 'file', accept: 'image/*' }
        }
      },
      formRules: {
        // 表单验证规则
        name: { required: true },
        gender: { required: true },
        ethnicity: { required: true },
        birthDate: { required: true },
        idCard: { required: true, pattern: /(^\d{18}$)|(^\d{17}(\d|X|x)$)/ },
        nativePlace: { required: true },
        politicalStatus: { required: true },
        healthStatus: { required: true },
        education: { required: true },
        graduateSchool: { required: true },
        orgName: { required: true },
        job: { required: true },
        title: { required: true },
        isPublicOfficial: { required: true },
        phone: { required: true, pattern: /^1[3-9]\d{9}$/ },
        email: { required: true, pattern: /^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$/ },
        workTime: { required: true, min: 0 },
        bankName: { required: true },
        bankAccount: { required: true, pattern: /^\d{16,19}$/ },
        primaryMajor: { required: true },
        secondMajor: { required: true },
        thirdMajor: { required: true },
        fourthMajor: { required: true },
        fifthMajor: { required: true },
        qualification: { required: true },
        isAcademician: { required: true },
        isDesignMaster: { required: true },
        isSpecialExpert: { required: true },
        isSpecialTalent: { required: true },
        // 工作履历验证规则
        orgName: { required: true },
        startDate: { required: true },
        endDate: { required: true },
        jobTitle: { required: true },
        jobDuty: { required: true },
        jobDescription: { required: true },
        // 附件上传验证规则
        idCardFrontUrl: { required: true },
        idCardBackUrl: { required: true },
        degreeCertificateUrl: { required: true },
        professionalCertificateUrl: { required: true }
      },
      previewDialogVisible: false,
      previewUrl: '',
      previewFileName: '',
      expertId: null,
      isFromDashboard: false,
      attachInfo: null, // 存储附件信息
      attachmentFiles: {
        idCard: { fileId: null, fileName: '未上传文件', url: null, address: null },
        certificate: { fileId: null, fileName: '未上传文件', url: null, address: null },
        qualification: { fileId: null, fileName: '未上传文件', url: null, address: null },
        supportMater: { fileId: null, fileName: '未上传文件', url: null, address: null },
        applicationForm: { fileId: null, fileName: '未上传文件', url: null, address: null }
      },
      hasLoadedAttachments: false, 
      // 性别选项
      sexs: [
        {
          value: "男",
          label: "男",
        },
        {
          value: "女",
          label: "女",
        },
      ],
      // 政治面貌选项
      politicalStatus: [
        {
          value: "中共党员",
          label: "中共党员",
        },
        {
          value: "中共预备党员",
          label: "中共预备党员",
        },
        {
          value: "共青团员",
          label: "共青团员",
        },
        {
          value: "民主党派成员",
          label: "民主党派成员",
        },
        {
          value: "无党派人士",
          label: "无党派人士",
        },
        {
          value: "群众",
          label: "群众",
        },
      ],
      // 学历选项
      education: [
        {
          value: "博士研究生",
          label: "博士研究生",
        },
        {
          value: "硕士研究生",
          label: "硕士研究生",
        },
        {
          value: "大学本科",
          label: "大学本科",
        },
        {
          value: "大学专科",
          label: "大学专科",
        },
        {
          value: "高中/中专",
          label: "高中/中专",
        },
        {
          value: "初中及以下",
          label: "初中及以下",
        },
      ],
      // 职称选项
      titles: [
        {
          value: "副高级职称",
          label: "副高级职称",
        },
        {
          value: "正高级职称",
          label: "正高级职称",
        },
        {
          value: "同等执业资格",
          label: "同等执业资格",
        },
        {
          value: "其他",
          label: "其他",
        },
      ],
      // 籍贯选项（
      citys: [
        {
          children: [
            {
              value: "石家庄市",
              label: "石家庄市",
            },
            {
              value: "邯郸市",
              label: "邯郸市",
            },
            {
              value: "唐山市",
              label: "唐山市",
            },
            {
              value: "保定市",
              label: "保定市",
            },
            {
              value: "秦皇岛市",
              label: "秦皇岛市",
            },
            {
              value: "邢台市",
              label: "邢台市",
            },
            {
              value: "张家口市",
              label: "张家口市",
            },
            {
              value: "承德市",
              label: "承德市",
            },
            {
              value: "沧州市",
              label: "沧州市",
            },
            {
              value: "廊坊市",
              label: "廊坊市",
            },
            {
              value: "衡水市",
              label: "衡水市",
            },
            {
              value: "辛集市",
              label: "辛集市",
            },
            {
              value: "晋州市",
              label: "晋州市",
            },
            {
              value: "新乐市",
              label: "新乐市",
            },
            {
              value: "遵化市",
              label: "遵化市",
            },
            {
              value: "迁安市",
              label: "迁安市",
            },
            {
              value: "霸州市",
              label: "霸州市",
            },
            {
              value: "三河市",
              label: "三河市",
            },
            {
              value: "定州市",
              label: "定州市",
            },
            {
              value: "涿州市",
              label: "涿州市",
            },
            {
              value: "安国市",
              label: "安国市",
            },
            {
              value: "高碑店市",
              label: "高碑店市",
            },
            {
              value: "泊头市",
              label: "泊头市",
            },
            {
              value: "任丘市",
              label: "任丘市",
            },
            {
              value: "黄骅市",
              label: "黄骅市",
            },
            {
              value: "河间市",
              label: "河间市",
            },
            {
              value: "冀州市",
              label: "冀州市",
            },
            {
              value: "深州市",
              label: "深州市",
            },
            {
              value: "南宫市",
              label: "南宫市",
            },
            {
              value: "沙河市",
              label: "沙河市",
            },
            {
              value: "武安市",
              label: "武安市",
            },
          ],
          value: "河北省",
          label: "河北省",
        },
        {
          children: [
            {
              value: "太原市",
              label: "太原市",
            },
            {
              value: "大同市",
              label: "大同市",
            },
            {
              value: "朔州市",
              label: "朔州市",
            },
            {
              value: "阳泉市",
              label: "阳泉市",
            },
            {
              value: "长治市",
              label: "长治市",
            },
            {
              value: "晋城市",
              label: "晋城市",
            },
            {
              value: "忻州市",
              label: "忻州市",
            },
            {
              value: "吕梁市",
              label: "吕梁市",
            },
            {
              value: "晋中市",
              label: "晋中市",
            },
            {
              value: "临汾市",
              label: "临汾市",
            },
            {
              value: "运城市",
              label: "运城市",
            },
            {
              value: "古交市",
              label: "古交市",
            },
            {
              value: "潞城市",
              label: "潞城市",
            },
            {
              value: "高平市",
              label: "高平市",
            },
            {
              value: "原平市",
              label: "原平市",
            },
            {
              value: "孝义市",
              label: "孝义市",
            },
            {
              value: "汾阳市",
              label: "汾阳市",
            },
            {
              value: "介休市",
              label: "介休市",
            },
            {
              value: "侯马市",
              label: "侯马市",
            },
            {
              value: "霍州市",
              label: "霍州市",
            },
            {
              value: "永济市",
              label: "永济市",
            },
            {
              value: "河津市",
              label: "河津市",
            },
          ],
          value: "山西省",
          label: "山西省",
        },
        {
          children: [
            {
              value: "呼和浩特市",
              label: "呼和浩特市",
            },
            {
              value: "包头市",
              label: "包头市",
            },
            {
              value: "乌海市",
              label: "乌海市",
            },
            {
              value: "赤峰市",
              label: "赤峰市",
            },
            {
              value: "呼伦贝尔市",
              label: "呼伦贝尔市",
            },
            {
              value: "通辽市",
              label: "通辽市",
            },
            {
              value: "乌兰察布市",
              label: "乌兰察布市",
            },
            {
              value: "鄂尔多斯市",
              label: "鄂尔多斯市",
            },
            {
              value: "巴彦淖尔市",
              label: "巴彦淖尔市",
            },
            {
              value: "满洲里市",
              label: "满洲里市",
            },
            {
              value: "扎兰屯市",
              label: "扎兰屯市",
            },
            {
              value: "牙克石市",
              label: "牙克石市",
            },
            {
              value: "根河市",
              label: "根河市",
            },
            {
              value: "额尔古纳市",
              label: "额尔古纳市",
            },
            {
              value: "乌兰浩特市",
              label: "乌兰浩特市",
            },
            {
              value: "阿尔山市",
              label: "阿尔山市",
            },
            {
              value: "霍林郭勒市",
              label: "霍林郭勒市",
            },
            {
              value: "锡林浩特市",
              label: "锡林浩特市",
            },
            {
              value: "二连浩特市",
              label: "二连浩特市",
            },
            {
              value: "丰镇市",
              label: "丰镇市",
            },
          ],
          value: "内蒙古自治区",
          label: "内蒙古自治区",
        },
        {
          children: [
            {
              value: "沈阳市",
              label: "沈阳市",
            },
            {
              value: "大连市",
              label: "大连市",
            },
            {
              value: "朝阳市",
              label: "朝阳市",
            },
            {
              value: "阜新市",
              label: "阜新市",
            },
            {
              value: "铁岭市",
              label: "铁岭市",
            },
            {
              value: "抚顺市",
              label: "抚顺市",
            },
            {
              value: "本溪市",
              label: "本溪市",
            },
            {
              value: "辽阳市",
              label: "辽阳市",
            },
            {
              value: "鞍山市",
              label: "鞍山市",
            },
            {
              value: "丹东市",
              label: "丹东市",
            },
            {
              value: "营口市",
              label: "营口市",
            },
            {
              value: "盘锦市",
              label: "盘锦市",
            },
            {
              value: "锦州市",
              label: "锦州市",
            },
            {
              value: "葫芦岛市",
              label: "葫芦岛市",
            },
            {
              value: "新民市",
              label: "新民市",
            },
            {
              value: "瓦房店市",
              label: "瓦房店市",
            },
            {
              value: "庄河市",
              label: "庄河市",
            },
            {
              value: "北票市",
              label: "北票市",
            },
            {
              value: "凌源市",
              label: "凌源市",
            },
            {
              value: "调兵山市",
              label: "调兵山市",
            },
            {
              value: "开原市",
              label: "开原市",
            },
            {
              value: "灯塔市",
              label: "灯塔市",
            },
            {
              value: "海城市",
              label: "海城市",
            },
            {
              value: "凤城市",
              label: "凤城市",
            },
            {
              value: "东港市",
              label: "东港市",
            },
            {
              value: "大石桥市",
              label: "大石桥市",
            },
            {
              value: "盖州市",
              label: "盖州市",
            },
            {
              value: "凌海市",
              label: "凌海市",
            },
            {
              value: "北镇市",
              label: "北镇市",
            },
            {
              value: "兴城市",
              label: "兴城市",
            },
          ],
          value: "辽宁省",
          label: "辽宁省",
        },
        {
          children: [
            {
              value: "长春市",
              label: "长春市",
            },
            {
              value: "吉林市",
              label: "吉林市",
            },
            {
              value: "白城市",
              label: "白城市",
            },
            {
              value: "松原市",
              label: "松原市",
            },
            {
              value: "四平市",
              label: "四平市",
            },
            {
              value: "辽源市",
              label: "辽源市",
            },
            {
              value: "通化市",
              label: "通化市",
            },
            {
              value: "白山市",
              label: "白山市",
            },
            {
              value: "德惠市",
              label: "德惠市",
            },
            {
              value: "榆树市",
              label: "榆树市",
            },
            {
              value: "磐石市",
              label: "磐石市",
            },
            {
              value: "蛟河市",
              label: "蛟河市",
            },
            {
              value: "桦甸市",
              label: "桦甸市",
            },
            {
              value: "舒兰市",
              label: "舒兰市",
            },
            {
              value: "洮南市",
              label: "洮南市",
            },
            {
              value: "大安市",
              label: "大安市",
            },
            {
              value: "双辽市",
              label: "双辽市",
            },
            {
              value: "公主岭市",
              label: "公主岭市",
            },
            {
              value: "梅河口市",
              label: "梅河口市",
            },
            {
              value: "集安市",
              label: "集安市",
            },
            {
              value: "临江市",
              label: "临江市",
            },
            {
              value: "延吉市",
              label: "延吉市",
            },
            {
              value: "图们市",
              label: "图们市",
            },
            {
              value: "敦化市",
              label: "敦化市",
            },
            {
              value: "珲春市",
              label: "珲春市",
            },
            {
              value: "龙井市",
              label: "龙井市",
            },
            {
              value: "和龙市",
              label: "和龙市",
            },
            {
              value: "扶余市",
              value: "扶余市",
            },
          ],
          value: "吉林省",
          label: "吉林省",
        },
        {
          children: [
            {
              value: "哈尔滨市",
              label: "哈尔滨市",
            },
            {
              value: "齐齐哈尔市",
              label: "齐齐哈尔市",
            },
            {
              value: "黑河市",
              label: "黑河市",
            },
            {
              value: "大庆市",
              label: "大庆市",
            },
            {
              value: "伊春市",
              label: "伊春市",
            },
            {
              value: "鹤岗市",
              label: "鹤岗市",
            },
            {
              value: "佳木斯市",
              label: "佳木斯市",
            },
            {
              value: "双鸭山市",
              label: "双鸭山市",
            },
            {
              value: "七台河市",
              label: "七台河市",
            },
            {
              value: "鸡西市",
              label: "鸡西市",
            },
            {
              value: "牡丹江市",
              label: "牡丹江市",
            },
            {
              value: "绥化市",
              label: "绥化市",
            },
            {
              value: "尚志市",
              label: "尚志市",
            },
            {
              value: "五常市",
              label: "五常市",
            },
            {
              value: "讷河市",
              label: "讷河市",
            },
            {
              value: "北安市",
              label: "北安市",
            },
            {
              value: "五大连池市",
              label: "五大连池市",
            },
            {
              value: "铁力市",
              label: "铁力市",
            },
            {
              value: "同江市",
              label: "同江市",
            },
            {
              value: "富锦市",
              label: "富锦市",
            },
            {
              value: "虎林市",
              label: "虎林市",
            },
            {
              value: "密山市",
              label: "密山市",
            },
            {
              value: "绥芬河市",
              label: "绥芬河市",
            },
            {
              value: "海林市",
              label: "海林市",
            },
            {
              value: "宁安市",
              label: "宁安市",
            },
            {
              value: "安达市",
              label: "安达市",
            },
            {
              value: "肇东市",
              label: "肇东市",
            },
            {
              value: "海伦市",
              label: "海伦市",
            },
            {
              value: "穆棱市",
              label: "穆棱市",
            },
            {
              value: "东宁市",
              label: "东宁市",
            },
            {
              value: "抚远市",
              label: "抚远市",
            },
          ],
          value: "黑龙江省",
          label: "黑龙江省",
        },
        {
          children: [
            {
              value: "南京市",
              label: "南京市",
            },
            {
              value: "徐州市",
              label: "徐州市",
            },
            {
              value: "连云港市",
              label: "连云港市",
            },
            {
              value: "宿迁市",
              label: "宿迁市",
            },
            {
              value: "淮安市",
              label: "淮安市",
            },
            {
              value: "盐城市",
              label: "盐城市",
            },
            {
              value: "扬州市",
              label: "扬州市",
            },
            {
              value: "泰州市",
              label: "泰州市",
            },
            {
              value: "南通市",
              label: "南通市",
            },
            {
              value: "镇江市",
              label: "镇江市",
            },
            {
              value: "常州市",
              label: "常州市",
            },
            {
              value: "无锡市",
              label: "无锡市",
            },
            {
              value: "苏州市",
              label: "苏州市",
            },
            {
              value: "常熟市",
              label: "常熟市",
            },
            {
              value: "张家港市",
              label: "张家港市",
            },
            {
              value: "太仓市",
              label: "太仓市",
            },
            {
              value: "昆山市",
              label: "昆山市",
            },
            {
              value: "江阴市",
              label: "江阴市",
            },
            {
              value: "宜兴市",
              label: "宜兴市",
            },
            {
              value: "溧阳市",
              label: "溧阳市",
            },
            {
              value: "扬中市",
              label: "扬中市",
            },
            {
              value: "句容市",
              label: "句容市",
            },
            {
              value: "丹阳市",
              label: "丹阳市",
            },
            {
              value: "如皋市",
              label: "如皋市",
            },
            {
              value: "海门市",
              label: "海门市",
            },
            {
              value: "启东市",
              label: "启东市",
            },
            {
              value: "高邮市",
              label: "高邮市",
            },
            {
              value: "仪征市",
              label: "仪征市",
            },
            {
              value: "兴化市",
              label: "兴化市",
            },
            {
              value: "泰兴市",
              label: "泰兴市",
            },
            {
              value: "靖江市",
              label: "靖江市",
            },
            {
              value: "东台市",
              label: "东台市",
            },
            {
              value: "邳州市",
              label: "邳州市",
            },
            {
              value: "新沂市",
              label: "新沂市",
            },
          ],
          value: "江苏省",
          label: "江苏省",
        },
        {
          children: [
            {
              value: "杭州市",
              label: "杭州市",
            },
            {
              value: "宁波市",
              label: "宁波市",
            },
            {
              value: "湖州市",
              label: "湖州市",
            },
            {
              value: "嘉兴市",
              label: "嘉兴市",
            },
            {
              value: "舟山市",
              label: "舟山市",
            },
            {
              value: "绍兴市",
              label: "绍兴市",
            },
            {
              value: "衢州市",
              label: "衢州市",
            },
            {
              value: "金华市",
              label: "金华市",
            },
            {
              value: "台州市",
              label: "台州市",
            },
            {
              value: "温州市",
              label: "温州市",
            },
            {
              value: "丽水市",
              label: "丽水市",
            },
            {
              value: "临安市",
              label: "临安市",
            },
            {
              value: "建德市",
              label: "建德市",
            },
            {
              value: "慈溪市",
              label: "慈溪市",
            },
            {
              value: "余姚市",
              label: "余姚市",
            },
            {
              value: "平湖市",
              label: "平湖市",
            },
            {
              value: "海宁市",
              label: "海宁市",
            },
            {
              value: "桐乡市",
              label: "桐乡市",
            },
            {
              value: "诸暨市",
              label: "诸暨市",
            },
            {
              value: "嵊州市",
              label: "嵊州市",
            },
            {
              value: "江山市",
              label: "江山市",
            },
            {
              value: "兰溪市",
              label: "兰溪市",
            },
            {
              value: "永康市",
              label: "永康市",
            },
            {
              value: "义乌市",
              label: "义乌市",
            },
            {
              value: "东阳市",
              label: "东阳市",
            },
            {
              value: "临海市",
              label: "临海市",
            },
            {
              value: "温岭市",
              label: "温岭市",
            },
            {
              value: "瑞安市",
              label: "瑞安市",
            },
            {
              value: "乐清市",
              label: "乐清市",
            },
            {
              value: "龙泉市",
              label: "龙泉市",
            },
          ],
          value: "浙江省",
          label: "浙江省",
        },
        {
          children: [
            {
              value: "合肥市",
              label: "合肥市",
            },
            {
              value: "芜湖市",
              label: "芜湖市",
            },
            {
              value: "蚌埠市",
              label: "蚌埠市",
            },
            {
              value: "淮南市",
              label: "淮南市",
            },
            {
              value: "马鞍山市",
              label: "马鞍山市",
            },
            {
              value: "淮北市",
              label: "淮北市",
            },
            {
              value: "铜陵市",
              label: "铜陵市",
            },
            {
              value: "安庆市",
              label: "安庆市",
            },
            {
              value: "黄山市",
              label: "黄山市",
            },
            {
              value: "滁州市",
              label: "滁州市",
            },
            {
              value: "阜阳市",
              label: "阜阳市",
            },
            {
              value: "宿州市",
              label: "宿州市",
            },
            {
              value: "六安市",
              label: "六安市",
            },
            {
              value: "亳州市",
              label: "亳州市",
            },
            {
              value: "池州市",
              label: "池州市",
            },
            {
              value: "宣城市",
              label: "宣城市",
            },
            {
              value: "巢湖市",
              label: "巢湖市",
            },
            {
              value: "桐城市",
              label: "桐城市",
            },
            {
              value: "天长市",
              label: "天长市",
            },
            {
              value: "明光市",
              label: "明光市",
            },
            {
              value: "界首市",
              label: "界首市",
            },
            {
              value: "宁国市",
              label: "宁国市",
            },
          ],
          value: "安徽省",
          label: "安徽省",
        },
        {
          children: [
            {
              value: "厦门市",
              label: "厦门市",
            },
            {
              value: "福州市",
              label: "福州市",
            },
            {
              value: "南平市",
              label: "南平市",
            },
            {
              value: "三明市",
              label: "三明市",
            },
            {
              value: "莆田市",
              label: "莆田市",
            },
            {
              value: "泉州市",
              label: "泉州市",
            },
            {
              value: "漳州市",
              label: "漳州市",
            },
            {
              value: "龙岩市",
              label: "龙岩市",
            },
            {
              value: "宁德市",
              label: "宁德市",
            },
            {
              value: "福清市",
              label: "福清市",
            },
            {
              value: "长乐市",
              label: "长乐市",
            },
            {
              value: "邵武市",
              label: "邵武市",
            },
            {
              value: "武夷山市",
              label: "武夷山市",
            },
            {
              value: "建瓯市",
              label: "建瓯市",
            },
            {
              value: "永安市",
              label: "永安市",
            },
            {
              value: "石狮市",
              label: "石狮市",
            },
            {
              value: "晋江市",
              label: "晋江市",
            },
            {
              value: "南安市",
              label: "南安市",
            },
            {
              value: "龙海市",
              label: "龙海市",
            },
            {
              value: "漳平市",
              label: "漳平市",
            },
            {
              value: "福安市",
              label: "福安市",
            },
            {
              value: "福鼎市",
              label: "福鼎市",
            },
          ],
          value: "福建省",
          label: "福建省",
        },
        {
          children: [
            {
              value: "南昌市",
              label: "南昌市",
            },
            {
              value: "九江市",
              label: "九江市",
            },
            {
              value: "景德镇市",
              label: "景德镇市",
            },
            {
              value: "鹰潭市",
              label: "鹰潭市",
            },
            {
              value: "新余市",
              label: "新余市",
            },
            {
              value: "萍乡市",
              label: "萍乡市",
            },
            {
              value: "赣州市",
              label: "赣州市",
            },
            {
              value: "上饶市",
              label: "上饶市",
            },
            {
              value: "抚州市",
              label: "抚州市",
            },
            {
              value: "宜春市",
              label: "宜春市",
            },
            {
              value: "吉安市",
              label: "吉安市",
            },
            {
              value: "瑞昌市",
              label: "瑞昌市",
            },
            {
              value: "共青城市",
              label: "共青城市",
            },
            {
              value: "乐平市",
              label: "乐平市",
            },
            {
              value: "瑞金市",
              label: "瑞金市",
            },
            {
              value: "德兴市",
              label: "德兴市",
            },
            {
              value: "丰城市",
              label: "丰城市",
            },
            {
              value: "樟树市",
              label: "樟树市",
            },
            {
              value: "高安市",
              label: "高安市",
            },
            {
              value: "井冈山市",
              label: "井冈山市",
            },
            {
              value: "贵溪市",
              label: "贵溪市",
            },
          ],
          value: "江西省",
          label: "江西省",
        },
        {
          children: [
            {
              value: "济南市",
              label: "济南市",
            },
            {
              value: "青岛市",
              label: "青岛市",
            },
            {
              value: "聊城市",
              label: "聊城市",
            },
            {
              value: "德州市",
              label: "德州市",
            },
            {
              value: "东营市",
              label: "东营市",
            },
            {
              value: "淄博市",
              label: "淄博市",
            },
            {
              value: "潍坊市",
              label: "潍坊市",
            },
            {
              value: "烟台市",
              label: "烟台市",
            },
            {
              value: "威海市",
              label: "威海市",
            },
            {
              value: "日照市",
              label: "日照市",
            },
            {
              value: "临沂市",
              label: "临沂市",
            },
            {
              value: "枣庄市",
              label: "枣庄市",
            },
            {
              value: "济宁市",
              label: "济宁市",
            },
            {
              value: "泰安市",
              label: "泰安市",
            },
            {
              value: "莱芜市",
              label: "莱芜市",
            },
            {
              value: "滨州市",
              label: "滨州市",
            },
            {
              value: "菏泽市",
              label: "菏泽市",
            },
            {
              value: "胶州市",
              label: "胶州市",
            },
            {
              value: "即墨市",
              label: "即墨市",
            },
            {
              value: "平度市",
              label: "平度市",
            },
            {
              value: "莱西市",
              label: "莱西市",
            },
            {
              value: "临清市",
              label: "临清市",
            },
            {
              value: "乐陵市",
              label: "乐陵市",
            },
            {
              value: "禹城市",
              label: "禹城市",
            },
            {
              value: "安丘市",
              label: "安丘市",
            },
            {
              value: "昌邑市",
              label: "昌邑市",
            },
            {
              value: "高密市",
              label: "高密市",
            },
            {
              value: "青州市",
              label: "青州市",
            },
            {
              value: "诸城市",
              label: "诸城市",
            },
            {
              value: "寿光市",
              label: "寿光市",
            },
            {
              value: "栖霞市",
              label: "栖霞市",
            },
            {
              value: "海阳市",
              label: "海阳市",
            },
            {
              value: "龙口市",
              label: "龙口市",
            },
            {
              value: "莱阳市",
              label: "莱阳市",
            },
            {
              value: "莱州市",
              label: "莱州市",
            },
            {
              value: "蓬莱市",
              label: "蓬莱市",
            },
            {
              value: "招远市",
              label: "招远市",
            },
            {
              value: "荣成市",
              label: "荣成市",
            },
            {
              value: "乳山市",
              label: "乳山市",
            },
            {
              value: "滕州市",
              label: "滕州市",
            },
            {
              value: "曲阜市",
              label: "曲阜市",
            },
            {
              value: "邹城市",
              label: "邹城市",
            },
            {
              value: "新泰市",
              label: "新泰市",
            },
            {
              value: "肥城市",
              label: "肥城市",
            },
          ],
          value: "山东省",
          label: "山东省",
        },
        {
          children: [
            {
              value: "郑州市",
              label: "郑州市",
            },
            {
              value: "开封市",
              label: "开封市",
            },
            {
              value: "洛阳市",
              label: "洛阳市",
            },
            {
              value: "平顶山市",
              label: "平顶山市",
            },
            {
              value: "安阳市",
              label: "安阳市",
            },
            {
              value: "鹤壁市",
              label: "鹤壁市",
            },
            {
              value: "新乡市",
              label: "新乡市",
            },
            {
              value: "焦作市",
              label: "焦作市",
            },
            {
              value: "濮阳市",
              label: "濮阳市",
            },
            {
              value: "许昌市",
              label: "许昌市",
            },
            {
              value: "漯河市",
              label: "漯河市",
            },
            {
              value: "三门峡市",
              label: "三门峡市",
            },
            {
              value: "南阳市",
              label: "南阳市",
            },
            {
              value: "商丘市",
              label: "商丘市",
            },
            {
              value: "周口市",
              label: "周口市",
            },
            {
              value: "驻马店市",
              label: "驻马店市",
            },
            {
              value: "信阳市",
              label: "信阳市",
            },
            {
              value: "荥阳市",
              label: "荥阳市",
            },
            {
              value: "新郑市",
              label: "新郑市",
            },
            {
              value: "登封市",
              label: "登封市",
            },
            {
              value: "新密市",
              label: "新密市",
            },
            {
              value: "偃师市",
              label: "偃师市",
            },
            {
              value: "孟州市",
              label: "孟州市",
            },
            {
              value: "沁阳市",
              label: "沁阳市",
            },
            {
              value: "卫辉市",
              label: "卫辉市",
            },
            {
              value: "辉县市",
              label: "辉县市",
            },
            {
              value: "林州市",
              label: "林州市",
            },
            {
              value: "禹州市",
              label: "禹州市",
            },
            {
              value: "长葛市",
              label: "长葛市",
            },
            {
              value: "舞钢市",
              label: "舞钢市",
            },
            {
              value: "义马市",
              label: "义马市",
            },
            {
              value: "灵宝市",
              label: "灵宝市",
            },
            {
              value: "项城市",
              label: "项城市",
            },
            {
              value: "巩义市",
              label: "巩义市",
            },
            {
              value: "邓州市",
              label: "邓州市",
            },
            {
              value: "永城市",
              label: "永城市",
            },
            {
              value: "汝州市",
              label: "汝州市",
            },
            {
              value: "济源市",
              label: "济源市",
            },
          ],
          value: "河南省",
          label: "河南省",
        },
        {
          children: [
            {
              value: "武汉市",
              label: "武汉市",
            },
            {
              value: "十堰市",
              label: "十堰市",
            },
            {
              value: "襄阳市",
              label: "襄阳市",
            },
            {
              value: "荆门市",
              label: "荆门市",
            },
            {
              value: "孝感市",
              label: "孝感市",
            },
            {
              value: "黄冈市",
              label: "黄冈市",
            },
            {
              value: "鄂州市",
              label: "鄂州市",
            },
            {
              value: "黄石市",
              label: "黄石市",
            },
            {
              value: "咸宁市",
              label: "咸宁市",
            },
            {
              value: "荆州市",
              label: "荆州市",
            },
            {
              value: "宜昌市",
              label: "宜昌市",
            },
            {
              value: "随州市",
              label: "随州市",
            },
            {
              value: "丹江口市",
              label: "丹江口市",
            },
            {
              value: "老河口市",
              label: "老河口市",
            },
            {
              value: "枣阳市",
              label: "枣阳市",
            },
            {
              value: "宜城市",
              label: "宜城市",
            },
            {
              value: "钟祥市",
              label: "钟祥市",
            },
            {
              value: "汉川市",
              label: "汉川市",
            },
            {
              value: "应城市",
              label: "应城市",
            },
            {
              value: "安陆市",
              label: "安陆市",
            },
            {
              value: "广水市",
              label: "广水市",
            },
            {
              value: "麻城市",
              label: "麻城市",
            },
            {
              value: "武穴市",
              label: "武穴市",
            },
            {
              value: "大冶市",
              label: "大冶市",
            },
            {
              value: "赤壁市",
              label: "赤壁市",
            },
            {
              value: "石首市",
              label: "石首市",
            },
            {
              value: "洪湖市",
              label: "洪湖市",
            },
            {
              value: "松滋市",
              label: "松滋市",
            },
            {
              value: "宜都市",
              label: "宜都市",
            },
            {
              value: "枝江市",
              label: "枝江市",
            },
            {
              value: "当阳市",
              label: "当阳市",
            },
            {
              value: "恩施市",
              label: "恩施市",
            },
            {
              value: "利川市",
              label: "利川市",
            },
            {
              value: "仙桃市",
              label: "仙桃市",
            },
            {
              value: "天门市",
              label: "天门市",
            },
            {
              value: "潜江市",
              label: "潜江市",
            },
          ],
          value: "湖北省",
          label: "湖北省",
        },
        {
          children: [
            {
              value: "长沙市",
              label: "长沙市",
            },
            {
              value: "衡阳市",
              label: "衡阳市",
            },
            {
              value: "张家界市",
              label: "张家界市",
            },
            {
              value: "常德市",
              label: "常德市",
            },
            {
              value: "益阳市",
              label: "益阳市",
            },
            {
              value: "岳阳市",
              label: "岳阳市",
            },
            {
              value: "株洲市",
              label: "株洲市",
            },
            {
              value: "湘潭市",
              label: "湘潭市",
            },
            {
              value: "郴州市",
              label: "郴州市",
            },
            {
              value: "永州市",
              label: "永州市",
            },
            {
              value: "邵阳市",
              label: "邵阳市",
            },
            {
              value: "怀化市",
              label: "怀化市",
            },
            {
              value: "娄底市",
              label: "娄底市",
            },
            {
              value: "耒阳市",
              label: "耒阳市",
            },
            {
              value: "常宁市",
              label: "常宁市",
            },
            {
              value: "浏阳市",
              label: "浏阳市",
            },
            {
              value: "津市市",
              label: "津市市",
            },
            {
              value: "沅江市",
              label: "沅江市",
            },
            {
              value: "汨罗市",
              label: "汨罗市",
            },
            {
              value: "临湘市",
              label: "临湘市",
            },
            {
              value: "醴陵市",
              label: "醴陵市",
            },
            {
              value: "湘乡市",
              label: "湘乡市",
            },
            {
              value: "韶山市",
              label: "韶山市",
            },
            {
              value: "资兴市",
              label: "资兴市",
            },
            {
              value: "武冈市",
              label: "武冈市",
            },
            {
              value: "洪江市",
              label: "洪江市",
            },
            {
              value: "冷水江市",
              label: "冷水江市",
            },
            {
              value: "涟源市",
              label: "涟源市",
            },
            {
              value: "吉首市",
              label: "吉首市",
            },
          ],
          value: "湖南省",
          label: "湖南省",
        },
        {
          children: [
            {
              value: "广州市",
              label: "广州市",
            },
            {
              value: "深圳市",
              label: "深圳市",
            },
            {
              value: "清远市",
              label: "清远市",
            },
            {
              value: "韶关市",
              label: "韶关市",
            },
            {
              value: "河源市",
              label: "河源市",
            },
            {
              value: "梅州市",
              label: "梅州市",
            },
            {
              value: "潮州市",
              label: "潮州市",
            },
            {
              value: "汕头市",
              label: "汕头市",
            },
            {
              value: "揭阳市",
              label: "揭阳市",
            },
            {
              value: "汕尾市",
              label: "汕尾市",
            },
            {
              value: "惠州市",
              label: "惠州市",
            },
            {
              value: "东莞市",
              label: "东莞市",
            },
            {
              value: "珠海市",
              label: "珠海市",
            },
            {
              value: "中山市",
              label: "中山市",
            },
            {
              value: "江门市",
              label: "江门市",
            },
            {
              value: "佛山市",
              label: "佛山市",
            },
            {
              value: "肇庆市",
              label: "肇庆市",
            },
            {
              value: "云浮市",
              label: "云浮市",
            },
            {
              value: "阳江市",
              label: "阳江市",
            },
            {
              value: "茂名市",
              label: "茂名市",
            },
            {
              value: "湛江市",
              label: "湛江市",
            },
            {
              value: "英德市",
              label: "英德市",
            },
            {
              value: "连州市",
              label: "连州市",
            },
            {
              value: "乐昌市",
              label: "乐昌市",
            },
            {
              value: "南雄市",
              label: "南雄市",
            },
            {
              value: "兴宁市",
              label: "兴宁市",
            },
            {
              value: "普宁市",
              label: "普宁市",
            },
            {
              value: "陆丰市",
              label: "陆丰市",
            },
            {
              value: "恩平市",
              label: "恩平市",
            },
            {
              value: "台山市",
              label: "台山市",
            },
            {
              value: "开平市",
              label: "开平市",
            },
            {
              value: "鹤山市",
              label: "鹤山市",
            },
            {
              value: "四会市",
              label: "四会市",
            },
            {
              value: "罗定市",
              label: "罗定市",
            },
            {
              value: "阳春市",
              label: "阳春市",
            },
            {
              value: "化州市",
              label: "化州市",
            },
            {
              value: "信宜市",
              label: "信宜市",
            },
            {
              value: "高州市",
              label: "高州市",
            },
            {
              value: "吴川市",
              label: "吴川市",
            },
            {
              value: "廉江市",
              label: "廉江市",
            },
            {
              value: "雷州市",
              label: "雷州市",
            },
          ],
          value: "广东省",
          label: "广东省",
        },
        {
          children: [
            {
              value: "南宁市",
              label: "南宁市",
            },
            {
              value: "桂林市",
              label: "桂林市",
            },
            {
              value: "柳州市",
              label: "柳州市",
            },
            {
              value: "梧州市",
              label: "梧州市",
            },
            {
              value: "贵港市",
              label: "贵港市",
            },
            {
              value: "玉林市",
              label: "玉林市",
            },
            {
              value: "钦州市",
              label: "钦州市",
            },
            {
              value: "北海市",
              label: "北海市",
            },
            {
              value: "防城港市",
              label: "防城港市",
            },
            {
              value: "崇左市",
              label: "崇左市",
            },
            {
              value: "百色市",
              label: "百色市",
            },
            {
              value: "河池市",
              label: "河池市",
            },
            {
              value: "来宾市",
              label: "来宾市",
            },
            {
              value: "贺州市",
              label: "贺州市",
            },
            {
              value: "岑溪市",
              label: "岑溪市",
            },
            {
              value: "桂平市",
              label: "桂平市",
            },
            {
              value: "北流市",
              label: "北流市",
            },
            {
              value: "东兴市",
              label: "东兴市",
            },
            {
              value: "凭祥市",
              label: "凭祥市",
            },
            {
              value: "宜州市",
              label: "宜州市",
            },
            {
              value: "合山市",
              label: "合山市",
            },
            {
              value: "靖西市",
              label: "靖西市",
            },
          ],
          value: "广西壮族自治区",
          label: "广西壮族自治区",
        },
        {
          children: [
            {
              value: "海口市",
              label: "海口市",
            },
            {
              value: "三亚市",
              label: "三亚市",
            },
            {
              value: "三沙市",
              label: "三沙市",
            },
            {
              value: "儋州市",
              label: "儋州市",
            },
            {
              value: "文昌市",
              label: "文昌市",
            },
            {
              value: "琼海市",
              label: "琼海市",
            },
            {
              value: "万宁市",
              label: "万宁市",
            },
            {
              value: "东方市",
              label: "东方市",
            },
            {
              value: "五指山市",
              label: "五指山市",
            },
          ],
          value: "海南省",
          label: "海南省",
        },
        {
          value: "四川省",
          label: "四川省",
          children: [
            {
              value: "成都市",
              label: "成都市",
            },
            {
              value: "广元市",
              label: "广元市",
            },
            {
              value: "绵阳市",
              label: "绵阳市",
            },
            {
              value: "德阳市",
              label: "德阳市",
            },
            {
              value: "南充市",
              label: "南充市",
            },
            {
              value: "广安市",
              label: "广安市",
            },
            {
              value: "遂宁市",
              label: "遂宁市",
            },
            {
              value: "内江市",
              label: "内江市",
            },
            {
              value: "乐山市",
              label: "乐山市",
            },
            {
              value: "自贡市",
              label: "自贡市",
            },
            {
              value: "泸州市",
              label: "泸州市",
            },
            {
              value: "宜宾市",
              label: "宜宾市",
            },
            {
              value: "攀枝花市",
              label: "攀枝花市",
            },
            {
              value: "巴中市",
              label: "巴中市",
            },
            {
              value: "达州市",
              label: "达州市",
            },
            {
              value: "资阳市",
              label: "资阳市",
            },
            {
              value: "眉山市",
              label: "眉山市",
            },
            {
              value: "雅安市",
              label: "雅安市",
            },
            {
              value: "崇州市",
              label: "崇州市",
            },
            {
              value: "邛崃市",
              label: "邛崃市",
            },
            {
              value: "都江堰市",
              label: "都江堰市",
            },
            {
              value: "彭州市",
              label: "彭州市",
            },
            {
              value: "江油市",
              label: "江油市",
            },
            {
              value: "什邡市",
              label: "什邡市",
            },
            {
              value: "广汉市",
              label: "广汉市",
            },
            {
              value: "绵竹市",
              label: "绵竹市",
            },
            {
              value: "阆中市",
              label: "阆中市",
            },
            {
              value: "华蓥市",
              label: "华蓥市",
            },
            {
              value: "峨眉山市",
              label: "峨眉山市",
            },
            {
              value: "万源市",
              label: "万源市",
            },
            {
              value: "简阳市",
              label: "简阳市",
            },
            {
              value: "西昌市",
              label: "西昌市",
            },
            {
              value: "康定市",
              label: "康定市",
            },
            {
              value: "马尔康市",
              label: "马尔康市",
            },
            {
              value: "阿坝藏族羌族自治州",
              label: "阿坝藏族羌族自治州",
            },
            {
              value: "甘孜藏族自治州",
              label: "甘孜藏族自治州",
            },
            {
              value: "凉山彝族自治州",
              label: "凉山彝族自治州",
            },
          ],
        },
        {
          children: [
            {
              value: "贵阳市",
              label: "贵阳市",
            },
            {
              value: "六盘水市",
              label: "六盘水市",
            },
            {
              value: "遵义市",
              label: "遵义市",
            },
            {
              value: "安顺市",
              label: "安顺市",
            },
            {
              value: "毕节市",
              label: "毕节市",
            },
            {
              value: "铜仁市",
              label: "铜仁市",
            },
            {
              value: "黔东南苗族侗族自治州",
              label: "黔东南苗族侗族自治州",
            },
            {
              value: "黔南布依族苗族自治州",
              label: "黔南布依族苗族自治州",
            },
            {
              value: "黔西南布依族苗族自治州",
              label: "黔西南布依族苗族自治州",
            },
          ],
          value: "贵州省",
          label: "贵州省",
        },
        {
          children: [
            {
              value: "昆明市",
              label: "昆明市",
            },
            {
              value: "曲靖市",
              label: "曲靖市",
            },
            {
              value: "玉溪市",
              label: "玉溪市",
            },
            {
              value: "丽江市",
              label: "丽江市",
            },
            {
              value: "昭通市",
              label: "昭通市",
            },
            {
              value: "普洱市",
              label: "普洱市",
            },
            {
              value: "临沧市",
              label: "临沧市",
            },
            {
              value: "保山市",
              label: "保山市",
            },
            {
              value: "安宁市",
              label: "安宁市",
            },
            {
              value: "宣威市",
              label: "宣威市",
            },
            {
              value: "芒市",
              label: "芒市",
            },
            {
              value: "瑞丽市",
              label: "瑞丽市",
            },
            {
              value: "大理市",
              label: "大理市",
            },
            {
              value: "楚雄市",
              label: "楚雄市",
            },
            {
              value: "个旧市",
              label: "个旧市",
            },
            {
              value: "开远市",
              label: "开远市",
            },
            {
              value: "蒙自市",
              label: "蒙自市",
            },
            {
              value: "弥勒市",
              label: "弥勒市",
            },
            {
              value: "景洪市",
              label: "景洪市",
            },
            {
              value: "文山市",
              label: "文山市",
            },
            {
              value: "香格里拉市",
              label: "香格里拉市",
            },
            {
              value: "腾冲市",
              label: "腾冲市",
            },
          ],
          value: "云南省",
          label: "云南省",
        },
        {
          children: [
            {
              value: "西安市",
              label: "西安市",
            },
            {
              value: "延安市",
              label: "延安市",
            },
            {
              value: "铜川市",
              label: "铜川市",
            },
            {
              value: "渭南市",
              label: "渭南市",
            },
            {
              value: "咸阳市",
              label: "咸阳市",
            },
            {
              value: "宝鸡市",
              label: "宝鸡市",
            },
            {
              value: "汉中市",
              label: "汉中市",
            },
            {
              value: "榆林市",
              label: "榆林市",
            },
            {
              value: "商洛市",
              label: "商洛市",
            },
            {
              value: "安康市",
              label: "安康市",
            },
            {
              value: "韩城",
              label: "韩城",
            },
            {
              value: "华阴",
              label: "华阴",
            },
            {
              value: "兴平",
              label: "兴平",
            },
          ],
          value: "陕西省",
          label: "陕西省",
        },
        {
          children: [
            {
              value: "兰州市",
              label: "兰州市",
            },
            {
              value: "嘉峪关市",
              label: "嘉峪关市",
            },
            {
              value: "金昌市",
              label: "金昌市",
            },
            {
              value: "白银市",
              label: "白银市",
            },
            {
              value: "天水市",
              label: "天水市",
            },
            {
              value: "酒泉市",
              label: "酒泉市",
            },
            {
              value: "张掖市",
              label: "张掖市",
            },
            {
              value: "武威市",
              label: "武威市",
            },
            {
              value: "庆阳市",
              label: "庆阳市",
            },
            {
              value: "平凉市",
              label: "平凉市",
            },
            {
              value: "定西市",
              label: "定西市",
            },
            {
              value: "陇南市",
              label: "陇南市",
            },
            {
              value: "玉门市",
              label: "玉门市",
            },
            {
              value: "敦煌市",
              label: "敦煌市",
            },
            {
              value: "临夏市",
              label: "临夏市",
            },
            {
              value: "合作市",
              label: "合作市",
            },
          ],
          value: "甘肃省",
          label: "甘肃省",
        },
        {
          children: [
            {
              value: "西宁市",
              label: "西宁市",
            },
            {
              value: "海东市",
              label: "海东市",
            },
            {
              value: "格尔木市",
              label: "格尔木市",
            },
            {
              value: "德令哈市",
              label: "德令哈市",
            },
            {
              value: "玉树市",
              label: "玉树市",
            },
          ],
          value: "青海省",
          label: "青海省",
        },
        {
          children: [
            {
              value: "拉萨市",
              label: "拉萨市",
            },
            {
              value: "日喀则市",
              label: "日喀则市",
            },
            {
              value: "昌都市",
              label: "昌都市",
            },
            {
              value: "林芝市",
              label: "林芝市",
            },
            {
              value: "山南市",
              label: "山南市",
            },
          ],
          value: "西藏自治区",
          label: "西藏自治区",
        },
        {
          children: [
            {
              value: "银川市",
              label: "银川市",
            },
            {
              value: "石嘴山市",
              label: "石嘴山市",
            },
            {
              value: "吴忠市",
              label: "吴忠市",
            },
            {
              value: "中卫市",
              label: "中卫市",
            },
            {
              value: "固原市",
              label: "固原市",
            },
            {
              value: "灵武市",
              label: "灵武市",
            },
            {
              value: "青铜峡市",
              label: "青铜峡市",
            },
          ],
          value: "宁夏回族自治区",
          label: "宁夏回族自治区",
        },
        {
          children: [
            {
              value: "台北市",
              label: "台北市",
            },
            {
              value: "新北市",
              label: "新北市",
            },
            {
              value: "桃园市",
              label: "桃园市",
            },
            {
              value: "台中市",
              label: "台中市",
            },
            {
              value: "台南市",
              label: "台南市",
            },
            {
              value: "高雄市",
              label: "高雄市",
            },
            {
              value: "基隆市",
              label: "基隆市",
            },
            {
              value: "新竹市",
              label: "新竹市",
            },
            {
              value: "嘉义市",
              label: "嘉义市",
            },
          ],
          value: "台湾",
          label: "台湾",
        },
        {
          children: [
            {
              value: "北京市",
              label: "北京市",
            },
          ],
          value: "北京市",
          label: "北京市",
        },
        {
          children: [
            {
              value: "天津市",
              label: "天津市",
            },
          ],
          value: "天津市",
          label: "天津市",
        },
        {
          children: [
            {
              value: "上海市",
              label: "上海市",
            },
          ],
          value: "上海市",
          label: "上海市",
        },
        {
          children: [
            {
              value: "重庆市",
              label: "重庆市",
            },
          ],
          value: "重庆市",
          label: "重庆市",
        },
        {
          children: [
            {
              value: "香港特别行政区",
              label: "香港特别行政区",
            },
          ],
          value: "香港",
          label: "香港",
        },
        {
          children: [
            {
              value: "澳门特别行政区",
              label: "澳门特别行政区",
            },
          ],
          value: "澳门",
          label: "澳门",
        },
        {
          children: [
            {
              value: "乌鲁木齐市",
              label: "乌鲁木齐市",
            },
            {
              value: "克拉玛依市",
              label: "克拉玛依市",
            },
            {
              value: "吐鲁番市",
              label: "吐鲁番市",
            },
            {
              value: "哈密市",
              label: "哈密市",
            },
            {
              value: "喀什市",
              label: "喀什市",
            },
            {
              value: "阿克苏市",
              label: "阿克苏市",
            },
            {
              value: "和田市",
              label: "和田市",
            },
            {
              value: "阿图什市",
              label: "阿图什市",
            },
            {
              value: "阿拉山口市",
              label: "阿拉山口市",
            },
            {
              value: "博乐市",
              label: "博乐市",
            },
            {
              value: "昌吉市",
              label: "昌吉市",
            },
            {
              value: "阜康市",
              label: "阜康市",
            },
            {
              value: "库尔勒市",
              label: "库尔勒市",
            },
            {
              value: "伊宁市",
              label: "伊宁市",
            },
            {
              value: "奎屯市",
              label: "奎屯市",
            },
            {
              value: "塔城市",
              label: "塔城市",
            },
            {
              value: "乌苏市",
              label: "乌苏市",
            },
            {
              value: "阿勒泰市",
              label: "阿勒泰市",
            },
            {
              value: "霍尔果斯市",
              label: "霍尔果斯市",
            },
            {
              value: "石河子市",
              label: "石河子市",
            },
            {
              value: "阿拉尔市",
              label: "阿拉尔市",
            },
            {
              value: "图木舒克市",
              label: "图木舒克市",
            },
            {
              value: "五家渠市",
              label: "五家渠市",
            },
            {
              value: "北屯市",
              label: "北屯市",
            },
            {
              value: "铁门关市",
              label: "铁门关市",
            },
            {
              value: "双河市",
              label: "双河市",
            },
            {
              value: "可克达拉市",
              label: "可克达拉市",
            },
            {
              value: "昆玉市",
              label: "昆玉市",
            },
          ],
          value: "新疆维吾尔自治区",
          label: "新疆维吾尔自治区",
        },
      ],
      pickerOptions,
      // 专业选项
      options1: [
        {
          value: "建设管理",
          label: "建设管理",
        },
        {
          value: "计划管理",
          label: "计划管理",
        },
        {
          value: "质量管理",
          label: "质量管理",
        },
        {
          value: "水利规划",
          label: "水利规划",
        },
        {
          value: "水文泥沙",
          label: "水文泥沙",
        },
        {
          value: "水资源",
          label: "水资源",
        },
        {
          value: "节水评价",
          label: "节水评价",
        },
        {
          value: "水土保持",
          label: "水土保持",
        },
        {
          value: "农田水利",
          label: "农田水利",
        },
        {
          value: "城乡供水",
          label: "城乡供水",
        },
        {
          value: "水工结构",
          label: "水工结构",
        },
        {
          value: "河道治理",
          label: "河道治理",
        },
        {
          value: "工程地质与工程测绘",
          label: "工程地质与工程测绘",
        },
        {
          value: "水旱灾害防御抢险",
          label: "水旱灾害防御抢险",
        },
        {
          value: "工程造价与经济评价",
          label: "工程造价与经济评价",
        },
        {
          value: "征地移民",
          label: "征地移民",
        },
        {
          value: "电气机电与金属结构",
          label: "电气机电与金属结构",
        },
        {
          value: "水利政策法规",
          label: "水利政策法规",
        },
        {
          value: "施工组织与管理",
          label: "施工组织与管理",
        },
        {
          value: "水利信息化",
          label: "水利信息化",
        },
        {
          value: "工程管理",
          label: "工程管理",
        },
        {
          value: "节能评价",
          label: "节能评价",
        },
        {
          value: "资金管理",
          label: "资金管理",
        },
        {
          value: "水力发电",
          label: "水力发电",
        },
        {
          value: "劳动安全与工业卫生（安全生产）",
          label: "劳动安全与工业卫生（安全生产）",
        },
        {
          value: "环境影响评价",
          label: "环境影响评价",
        },
        {
          value: "社会稳定分析",
          label: "社会稳定分析",
        },
        {
          value: "质量检测",
          label: "质量检测",
        },
        {
          value: "水文化",
          label: "水文化",
        },
      ],
      options: [
        {
          value: "无",
          label: "无",
        },
        {
          value: "建设管理",
          label: "建设管理",
        },
        {
          value: "计划管理",
          label: "计划管理",
        },
        {
          value: "质量管理",
          label: "质量管理",
        },
        {
          value: "水利规划",
          label: "水利规划",
        },
        {
          value: "水文泥沙",
          label: "水文泥沙",
        },
        {
          value: "水资源",
          label: "水资源",
        },
        {
          value: "节水评价",
          label: "节水评价",
        },
        {
          value: "水土保持",
          label: "水土保持",
        },
        {
          value: "农田水利",
          label: "农田水利",
        },
        {
          value: "城乡供水",
          label: "城乡供水",
        },
        {
          value: "水工结构",
          label: "水工结构",
        },
        {
          value: "河道治理",
          label: "河道治理",
        },
        {
          value: "工程地质与工程测绘",
          label: "工程地质与工程测绘",
        },
        {
          value: "水旱灾害防御抢险",
          label: "水旱灾害防御抢险",
        },
        {
          value: "工程造价与经济评价",
          label: "工程造价与经济评价",
        },
        {
          value: "征地移民",
          label: "征地移民",
        },
        {
          value: "电气机电与金属结构",
          label: "电气机电与金属结构",
        },
        {
          value: "水利政策法规",
          label: "水利政策法规",
        },
        {
          value: "施工组织与管理",
          label: "施工组织与管理",
        },
        {
          value: "水利信息化",
          label: "水利信息化",
        },
        {
          value: "工程管理",
          label: "工程管理",
        },
        {
          value: "节能评价",
          label: "节能评价",
        },
        {
          value: "资金管理",
          label: "资金管理",
        },
        {
          value: "水力发电",
          label: "水力发电",
        },
        {
          value: "劳动安全与工业卫生（安全生产）",
          label: "劳动安全与工业卫生（安全生产）",
        },
        {
          value: "环境影响评价",
          label: "环境影响评价",
        },
        {
          value: "社会稳定分析",
          label: "社会稳定分析",
        },
        {
          value: "质量检测",
          label: "质量检测",
        },
        {
          value: "水文化",
          label: "水文化",
        },
      ],
      showMajorError: [0, 0, 0, 0, 0], 
      otherInfoForm: {
        id: '',
        expertId: '',
        researchResults: '',
        projectConsultation: '',
        createTime: '',
        updateTime: ''
      },
      isOtherInfoReadOnly: true,
      isSocialExperienceReadOnly: true,
      socialEditingIndex: -1,
      id: null,
      mode: 'add', // 默认为新增模式
      researchAchievements: '',
      projectMatters: '',
      hasLoadedPhoto: false, // 添加标记，避免重复加载照片
    }
  },
  watch: {
    row: {
      immediate: true,
      handler(newVal) {
        if (newVal) {
          // 先加载表格数据
          this.loadTableData(newVal);
          
          // 获取专家ID
          const expertId = newVal.expertId || newVal.id;
          if (expertId) {
            this.expertId = expertId;
            
            // 使用 Promise.all 并行加载附件和照片
            if (!this.hasLoadedAttachments || !this.hasLoadedPhoto) {
              Promise.all([
                !this.hasLoadedAttachments ? this.getAttachInfo(expertId) : Promise.resolve(),
                !this.hasLoadedPhoto ? this.loadPhotoData(newVal) : Promise.resolve()
              ]).catch(error => {
                console.error('加载附件或照片失败:', error);
              }).finally(() => {
                this.hasLoadedAttachments = true;
                this.hasLoadedPhoto = true;
              });
            }
          }
        }
      }
    }
  },
      async created() {
      // 获取路由参数
      const { id, expertId, mode } = this.$route.query;
      
      if (mode === 'edit') {
        // 编辑模式
        this.mode = 'edit';
        this.id = id;
        this.expertId = expertId;
        
        // 从 localStorage 获取专家数据
        const expertData = localStorage.getItem('currentExpertData');
        if (expertData) {
          const parsedData = JSON.parse(expertData);
          // 初始化基础数据
          this.initFormData(parsedData);
        }
        
        // 加载完整的专家信息
        if (this.expertId) {
          this.loadExpertInfo();
          // 加载附件信息
          await this.getAttachInfo(this.expertId);
          this.hasLoadedAttachments = true;
        }
        
        // 设置为编辑状态
        this.isBasicInfoReadOnly = false;
      } else {
        // 新增模式
        this.mode = 'add';
        // 设置为可编辑状态
        this.isBasicInfoReadOnly = false;
        this.isWorkExperienceReadOnly = false;
        this.isAttachmentReadOnly = false;
        // 初始化空表单
        this.initEmptyForm();
      }
      this.getExpertImage() // 在组件创建时获取专家图像
  },
  mounted() {
    console.log('当前专家信息:', this.row);
    if (this.row) {
      this.initializeFormData(this.row);
    }
  },
  computed: {
    isAdding() {
      return this.editingIndex === -1 && !this.isReadOnly;
    },
    isPdfFile() {
      return this.previewUrl.toLowerCase().endsWith('.pdf');
    },
    isImageFile() {
      const ext = this.previewUrl.toLowerCase();
      return ext.endsWith('.png') || ext.endsWith('.jpg') || ext.endsWith('.jpeg');
    }
  },
  methods: {
    // 初始化空表单（用于新增模式）
    initEmptyForm() {
      this.formData = {
        photoUrl: '',
        name: '',
        gender: '',
        // ... 其他需要的空字段
      };
      this.workExperienceList = [];
      this.socialExperienceList = [];
      // ... 其他需要初始化的数据
    },
    
    // 初始化表单数据（用于编辑模式）
    initFormData(data) {
      // 处理数据映射
      const mappedData = {
        ...data,
        nativePlace: data.nativePlace ? data.nativePlace.split('/') : [],  // 处理籍贯，将字符串分割为数组
        politicalStatus: data.politicalStatus,  // 处理政治面貌
        isPublicOfficial: this.convertToDisplayValue(data.isPublicOfficial),  // 处理是否为事业在职人员
      };

      // 处理专业字段，将字符串转换为数组
      const majorFields = ['primaryMajor', 'secondMajor', 'thirdMajor', 'fourthMajor', 'fifthMajor'];
      majorFields.forEach(field => {
        if (data[field]) {
          mappedData[field] = data[field].split('/');
        }
      });

      this.formData = {
        ...this.formData,
        ...mappedData
      };
    },
    
    // 加载专家详细信息（用于编辑模式）
    async loadExpertInfo() {
      try {
        const response = await getExpertBasicInfo(this.expertId);
        if (response && response.data) {
          this.initFormData(response.data);
          
          // 获取附件信息
          const attachResponse = await getExpertAttach(this.expertId);
          if (attachResponse.code === 200 && attachResponse.data) {
            // 处理附件信息
            this.handleAttachmentData(attachResponse.data);
          }
          
          // 获取其他相关信息（如工作经历等）
          await this.loadRelatedInfo();
        }
      } catch (error) {
        console.error('加载专家信息失败:', error);
        this.$message.error('加载专家信息失败，请重试');
      }
    },
    
    // 处理附件信息
    handleAttachmentData(attachData) {
      // 处理附件数据的逻辑
      this.formData.attachments = {
        idCard: attachData.idCard,
        certificate: attachData.certificate,
        qualification: attachData.qualification,
        supportMater: attachData.supportMater,
        applicationForm: attachData.applicationForm
      };
    },
    
    // 加载相关信息（工作经历等）
    async loadRelatedInfo() {
      try {
        // 加载工作经历
        const workResponse = await this.$http.get(`/admin/expertWorkExper/get/${this.expertId}`);
        if (workResponse && workResponse.data) {
          this.workExperienceList = workResponse.data.map(item => ({
            orgName: item.orgName || '',
            startDate: item.startDate || '',
            endDate: item.endDate || '',
            jobTitle: item.title || '',
            jobDuty: item.position || '',
            id: item.id,
            expertId: item.expertId
          }));
        }
        
        // 加载社会兼职情况
        const socialResponse = await this.$http.get(`/admin/expertSocialPart/get/${this.expertId}`);
        if (socialResponse && socialResponse.data) {
          this.socialExperienceList = socialResponse.data.map(item => ({
            id: item.id || '',
            expertId: item.expertId,
            orgName: item.orgName || '',
            startDate: item.startDate || '',
            endDate: item.endDate || '',
            role: item.role || '',
            createTime: item.createTime || '',
            updateTime: item.updateTime || ''
          }));
        }
        
        // 加载其他信息
        const otherResponse = await this.$http.get(`/admin/expertOtherInfo/get/${this.expertId}`);
        if (otherResponse && otherResponse.data) {
          this.otherInfoForm = otherResponse.data;
          this.researchAchievements = otherResponse.data.researchResults || '';
          this.projectMatters = otherResponse.data.projectConsultation || '';
          console.log('加载其他信息成功:', {
            researchAchievements: this.researchAchievements,
            projectMatters: this.projectMatters
          });
        }
      } catch (error) {
        console.error('加载相关信息失败:', error);
        this.$message.error('加载相关信息失败');
      }
    },
    
    // 保存表单
    async handleSaveBasicInfo() {
      try {
        // 基本数据验证
        if (!this.formData.name) {
          this.$message.warning('姓名不能为空');
          return;
        }
        if (!this.formData.phone) {
          this.$message.warning('手机号不能为空');
          return;
        }
        if (!this.formData.idCard) {
          this.$message.warning('身份证号不能为空');
          return;
        }

        // 新增校验：从事水利相关领域工作时间不得低于8年
        if (Number(this.formData.workTime) < 8) {
          this.$message.warning('从事水利相关领域工作时间不得低于8年');
          return;
        }

        // 构造保存的数据对象
        const saveData = {
          id: this.formData.id || '',
          expertId: this.formData.expertId || '',
          name: this.formData.name,
          gender: this.formData.gender,
          ethnicity: this.formData.ethnicity, // 添加民族字段
          birthDate: this.formData.birthDate,
          idCard: this.formData.idCard,
          nativePlace: Array.isArray(this.formData.nativePlace) ? this.formData.nativePlace.join('/') : this.formData.nativePlace,
          politicalStatus: this.formData.politicalStatus,
          education: this.formData.education,
          graduateSchool: this.formData.graduateSchool,
          workUnit: this.formData.workUnit,
          healthStatus: this.formData.healthStatus,
          job: this.formData.job,
          title: this.formData.title,
          isPublicOfficial: this.convertToBoolean(this.formData.isPublicOfficial),
          phone: this.formData.phone,
          email: this.formData.email,
          bankName: this.formData.bankName,
          bankAccount: this.formData.bankAccount,
          primaryMajor: Array.isArray(this.formData.primaryMajor) ? this.formData.primaryMajor.join('/') : this.formData.primaryMajor,
          secondMajor: Array.isArray(this.formData.secondMajor) ? this.formData.secondMajor.join('/') : this.formData.secondMajor,
          thirdMajor: Array.isArray(this.formData.thirdMajor) ? this.formData.thirdMajor.join('/') : this.formData.thirdMajor,
          fourthMajor: Array.isArray(this.formData.fourthMajor) ? this.formData.fourthMajor.join('/') : this.formData.fourthMajor,
          fifthMajor: Array.isArray(this.formData.fifthMajor) ? this.formData.fifthMajor.join('/') : this.formData.fifthMajor,
          workTime: this.formData.workTime,
          isAcademic: this.convertToBoolean(this.formData.isAcademic),
          isDesignMaster: this.convertToBoolean(this.formData.isDesignMaster),
          isSubsidy: this.convertToBoolean(this.formData.isSubsidy),
          isSpecial: this.convertToBoolean(this.formData.isSpecial),
          registeredQualification: this.formData.registeredQualification,
          photoUrl: this.formData.photoUrl || '' // 添加photoUrl字段
        };

        console.log('保存的数据：', saveData); // 调试用

        // 调用保存接口
        const response = await addOrUpdateExpert(saveData);
        
        if (response.code === 200) {
          this.$message.success('保存成功');
          // 更新表单数据
          if (response.data) {
            // 保持原有的photoUrl
            const currentPhotoUrl = this.formData.photoUrl;
            this.formData = { 
              ...this.formData, 
              ...response.data,
              photoUrl: currentPhotoUrl // 确保保留当前的photoUrl
            };
            this.expertId = response.data.expertId || this.expertId;

            // 如果有expertId，同时更新专家附件信息
            if (this.expertId && currentPhotoUrl) {
              try {
                const attachFormData = new FormData();
                attachFormData.append('photoUrl', currentPhotoUrl);
                const photoResponse = await uploadExpertAttach(this.expertId, attachFormData);
                if (photoResponse && photoResponse.code === 200) {
                  console.log('专家照片更新成功');
                }
              } catch (error) {
                // 仅在控制台记录错误，不向用户显示
                console.error('更新专家照片失败:', error);
              }
            }
          }
          // 切换为只读模式
          this.isBasicInfoReadOnly = true;
        } else {
          this.$message.error(response.message || '保存失败');
        }
      } catch (error) {
        console.error('保存失败:', error);
        this.$message.error('保存失败，请稍后重试');
      }
    },
    
    // 表单验证
    validateForm() {
      // 实现表单验证逻辑
      return true; // 临时返回 true
    },
    
    // 处理新增成功
    handleAddSuccess(data) {
      // 处理新增成功后的逻辑
      this.$router.push('/dashboard');
    },
    
    // 处理编辑成功
    handleEditSuccess() {
      // 处理编辑成功后的逻辑
      this.$router.push('/dashboard');
    },
    
    // 处理基本信息编辑
    handleEditBasicInfo() {
      this.isBasicInfoReadOnly = false;
      // 保存一份原始数据，用于取消编辑时恢复
      this.originalFormData = JSON.parse(JSON.stringify(this.formData));
    },
    
    // 加载专家数据
    async loadExpertData() {
      this.isLoading = true;
      try {
        // 从 localStorage 获取专家数据
        const expertData = JSON.parse(localStorage.getItem('currentExpertData'));
        if (expertData) {
          // 清除 localStorage 中的数据
          localStorage.removeItem('currentExpertData');
          
          // 如果需要获取更详细的数据，可以调用API
          const detailedData = await this.fetchExpertDetail(expertData.id);
          this.initializeFormData(detailedData || expertData);
          
          // 信息审核页的内容
          this.generateReviewContent();
        } else {
          this.$message.error('未找到专家数据');
          this.$router.push('/dashboard');
        }
      } catch (error) {
        console.error('加载专家数据失败:', error);
        this.$message.error('加载专家信息失败，请重试');
      } finally {
        this.isLoading = false;
      }
    },
    
    // 加载新专家表单
    async loadNewExpertForm() {
      this.isLoading = true;
      try {
        const response = await this.fetchUserData();
        this.initializeFormData(response);
        this.generateReviewContent();
      } catch (error) {
        console.error('获取用户数据失败:', error);
        // this.$message.error('加载个人信息失败，请稍后重试');
      } finally {
        this.isLoading = false;
      }
    },
    
    // 获取专家详细信息
    async fetchExpertDetail(expertId) {
      try {
        // 这里替换为实际的API调用
        const response = await new Promise(resolve => {
          setTimeout(() => {
            resolve({
              // 模拟更详细的专家数据
              id: expertId,
              user_name: "张三",
              gender: "男",
              ethnicity: "汉",
              birth_date: "1990-01-01",
              id_card: "110101199001011234",
              native_place: "北京市",
              political_status: "中共党员",
              health_status: "良好",
              education_level: "本科",
              graduated_school: "清华大学",
              current_work_unit: "水利部",
              current_duty: "工程师",
              professional_title: "中级",
              is_working: "是",
              phone_number: "13800138000",
              email: "zhangsan@example.com",
              working_years: 5,
              photoUrl: "https://picsum.photos/200/300",
              bank_name: "中国工商银行",
              bank_card_number: "6222021101011234567",
              major1: "水利工程",
              major2: "土木工程",
              major3: "",
              major4: "",
              major5: "",
              qualification: "注册土木工程师（水利水电工程）",
              is_academician: "否",
              is_design_master: "否",
              is_special_expert: "否",
              is_special_talent: "否",
              work_experience: [
                {
                  work_unit: "水利部",
                  start_time: "2020-01-01",
                  end_time: "至今",
                  job_title: "工程师",
                  job_duty: "项目负责人",
                  job_description: "负责水利工程项目的规划与实施"
                }
              ],
              social_experience: [
                {
                  partTimeUnit: "中国水利学会",
                  startDate: "2021-03-01",
                  endDate: "至今",
                  role: "会员"
                }
              ],
              research_achievements: "主持完成国家重点研发计划项目1项，发表SCI论文5篇",
              project_matters: "参与南水北调工程可行性研究论证等国家级项目",
              id_card_front_url: "https://example.com/id_card_front.jpg",
              id_card_back_url: "https://example.com/id_card_back.jpg",
              degree_certificate_url: "https://example.com/degree.jpg",
              professional_certificate_url: "https://example.com/cert.jpg",
              other_documents_url: "https://example.com/other.pdf"
            });
          }, 1000);
        });
        return response;
      } catch (error) {
        console.error('获取专家详细信息失败:', error);
        return null;
      }
    },
    
    // 初始化表单数据
    initializeFormData(apiData) {
      // 基本信息映射
      console.log(apiData);
      this.formData.name = apiData.name || '';
      this.formData.gender = apiData.gender || '';
      this.formData.ethnicity = apiData.ethnicity || '';
      this.formData.birthDate = apiData.birthDate || '';
      this.formData.idCard = apiData.idCard || '';
      this.formData.nativePlace = apiData.nativePlace || '';
      this.formData.politicalStatus = apiData.politicalStatus || '';
      this.formData.healthStatus = apiData.healthStatus || '';
      this.formData.education = apiData.education || '';
      this.formData.graduateSchool = apiData.graduateSchool || '';
      this.formData.workUnit = apiData.workUnit || '';
      this.formData.job = apiData.job || '';
      this.formData.title = apiData.title || '';
      this.formData.isPublicOfficial = apiData.isPublicOfficial === '是';
      this.formData.phone = apiData.phone || '';
      this.formData.email = apiData.email || '';
      this.formData.workTime = apiData.workTime || null;
      this.formData.photoUrl =  "data:image/jpeg;base64," +apiData.photoUrl || '';
      this.formData.bankName = apiData.bankName|| '';
      this.formData.bankAccount = apiData.bankAccount || '';
      
      // 专业信息映射
      this.formData.primaryMajor = apiData.primaryMajor || '';
      this.formData.secondMajor = apiData.secondMajor || '';
      this.formData.thirdMajor = apiData.thirdMajor || '';
      this.formData.fourthMajor = apiData.fourthMajor || '';
      this.formData.fifthMajor = apiData.fifthMajor || '';
      
      // 其他信息映射
      this.formData.qualification = apiData.qualification || '';
      this.formData.isAcademic = apiData.isAcademic === '是' ? '是' : '否';
      this.formData.isDesignMaster = apiData.isDesignMaster === '是' ? '是' : '否';
      this.formData.isSubsidy = apiData.isSubsidy === '是' ? '是' : '否';
      this.formData.isSpecial = apiData.isSpecial === '是' ? '是' : '否';
      
      // 工作履历映射
      this.workExperienceList = apiData.work_experience.map(exp => ({
        orgName: exp.orgName,
        startDate: exp.startDate,
        endDate: exp.endDate,
        jobTitle: exp.jobTitle,
        jobDuty: exp.jobDuty,
        jobDescription: exp.jobDescription
      }));
      
      // 社会兼、聘职情况映射
      this.socialExperienceList = apiData.social_experience.map(exp => ({
        id: exp.id || '',
        expertId: exp.expertId,
        orgName: exp.orgName || '',
        startDate: exp.startDate || '',
        endDate: exp.endDate || '',
        role: exp.role || ''
      }));
      
      // 其他信息映射
      this.researchResults = apiData.researchResults || '';
      this.projectMatters = apiData.project_matters || '';
      
      // 附件上传映射
      this.formData.idCardFrontUrl = apiData.id_card_front_url || '';
      this.formData.idCardBackUrl = apiData.id_card_back_url || '';
      this.formData.degreeCertificateUrl = apiData.degree_certificate_url || '';
      this.formData.professionalCertificateUrl = apiData.professional_certificate_url || '';
      this.formData.otherDocumentsUrl = apiData.other_documents_url || '';
      
      // 保存初始数据用于撤销修改
      this.initialData = JSON.parse(JSON.stringify(this.formData));
      this.initialWorkExperience = [...this.workExperienceList];
      this.initialSocialExperience = [...this.socialExperienceList];
      this.initialresearchResults = this.researchResults;
      this.initialProjectMatters = this.projectMatters;
      this.generateReviewContent()
    },
    
    // 信息审核页的内容
    generateReviewContent() {
      let content = "个人信息审核表\n\n";
      
      // 添加基本信息
      content += "一、基本信息\n";
      content += `姓名：${this.formData.name || '未填写'}\n`;
      content += `性别：${this.formData.gender || '未填写'}\n`;
      content += `民族：${this.formData.ethnicity|| '未填写'}\n`;
      content += `出生年月：${this.formData.birthDate || '未填写'}\n`;
      content += `身份证号：${this.formData.idCard || '未填写'}\n`;
      content += `政治面貌：${this.getDisplayValue('politicalStatus', this.formData.politicalStatus)}\n`;
      content += `学历：${this.getDisplayValue('education', this.formData.education)}\n`;
      content += `毕业院校：${this.formData.graduateSchool || '未填写'}\n`;
      content += `工作单位：${this.formData.workUnit || '未填写'}\n`;
      content += `职称：${this.getDisplayValue('title', this.formData.title)}\n`;
      content += `手机号：${this.formData.phone || '未填写'}\n\n`;
      
      // 添加专业信息
      content += "二、专业信息\n";
      content += `第一专业：${this.formData.primaryMajor || '未填写'}\n`;
      content += `第二专业：${this.formData.secondMajor || '未填写'}\n`;
      content += `第三专业：${this.formData.thirdMajor || '未填写'}\n\n`;
      
      // 添加工作履历
      content += "三、工作履历\n";
      this.workExperienceList.forEach((exp, index) => {
        content += `工作经历 ${index + 1}：\n`;
        content += `  单位：${exp.orgName || '未填写'}\n`;
        content += `  时间：${exp.startDate || '未填写'} 至 ${exp.endDate || '未填写'}\n`;
        content += `  职称：${exp.jobTitle || '未填写'}\n`;
        content += `  职务：${exp.jobDuty || '未填写'}\n`;
        content += `  描述：${exp.jobDescription || '未填写'}\n\n`;
      });
      
      // 添加社会兼、聘职情况
      content += "四、社会兼、聘职情况\n";
      this.socialExperienceList.forEach((exp, index) => {
        content += `兼职经历 ${index + 1}：\n`;
        content += `  单位：${exp.orgName || '未填写'}\n`;
        content += `  时间：${exp.startDate || '未填写'} 至 ${exp.endDate || '未填写'}\n`;
        content += `  身份：${exp.role || '未填写'}\n\n`;
      });
      
      // 添加其他信息
      content += "五、其他信息\n"; 
      content += `专业领域研究及成果：${this.researchResults || '未填写'}\n\n`;
      content += `参与项目咨询、审查、论证等事项：${this.projectMatters || '未填写'}\n\n`;
      
      // 添加附件信息
      content += "六、附件上传\n";
      content += `身份证：${this.formData.idCardFrontUrl ? '已上传' : '未上传'}\n`;
      content += `学历证书：${this.formData.degreeCertificateUrl ? '已上传' : '未上传'}\n`;
      content += `职业资格：${this.formData.professionalCertificateUrl ? '已上传' : '未上传'}\n`;
      
      this.databaseValue = content;
    },
    
    // 切换编辑/查看模式
    toggleEditMode() {
      this.isReadOnly = !this.isReadOnly;
      
      if (!this.isReadOnly) {
        // 进入编辑模式时，复制一份数据用于撤销
        this.tempData = JSON.parse(JSON.stringify(this.formData));
        this.tempWorkExperience = [...this.workExperienceList];
        this.tempSocialExperience = [...this.socialExperienceList];
        this.tempresearchResults = this.researchResults;
        this.tempProjectMatters = this.projectMatters;
      } else {
        // 退出编辑模式时，清空临时数据
        this.tempData = null;
        this.tempWorkExperience = null;
        this.tempSocialExperience = null;
        this.tempresearchResults = null;
        this.tempProjectMatters = null;
      }
    },
    
    // 保存表单
    async saveForm() {
      // 表单验证
      if (!this.validateForm()) {
        return;
      }
      
      this.isLoading = true;
      
      try {
        // 模拟API请求，实际项目中需替换为真实接口
        await this.submitFormData();
        
        // 信息审核页内容
        this.generateReviewContent();
        
        // 保存成功提示
        this.$message.success('保存成功');
        
        // 切换回查看模式
        this.isReadOnly = true;
        
        // 更新初始数据
        this.initialData = JSON.parse(JSON.stringify(this.formData));
        this.initialWorkExperience = [...this.workExperienceList];
        this.initialSocialExperience = [...this.socialExperienceList];
        this.initialresearchResults = this.researchResults;
        this.initialProjectMatters = this.projectMatters;
      } catch (error) {
        console.error('保存失败:', error);
        this.$message.error('保存失败，请稍后重试');
      } finally {
        this.isLoading = false;
      }
    },
    
    // 撤销修改
    cancelEdit() {
      // 恢复初始数据
      this.formData = JSON.parse(JSON.stringify(this.initialData));
      this.workExperienceList = [...this.initialWorkExperience];
      this.socialExperienceList = [...this.initialSocialExperience];
      this.researchResults = this.initialresearchResults;
      this.projectMatters = this.initialProjectMatters;
      
      // 切换回查看模式
      this.isReadOnly = true;
    },
    
    // 表单验证
    validateForm() {
      this.formErrors = {};
      let isValid = true;
      
      // 验证基本信息
      for (const [field, rules] of Object.entries(this.formRules)) {
        if (rules.required && !this.formData[field]) {
          this.formErrors[field] = '此字段为必填项';
          isValid = false;
        }
        
        if (rules.pattern && this.formData[field] && !new RegExp(rules.pattern).test(this.formData[field])) {
          this.formErrors[field] = '格式不正确';
          isValid = false;
        }
        
        if (rules.min !== undefined && this.formData[field] !== null && this.formData[field] < rules.min) {
          this.formErrors[field] = `最小值为${rules.min}`;
          isValid = false;
        }
      }
      
      // 验证工作履历
      if (this.workExperienceList.length === 0) {
        this.formErrors.workExperience = '至少需要添加一条工作经历';
        isValid = false;
      } else {
        // 验证每条工作履历
        for (let i = 0; i < this.workExperienceList.length; i++) {
          const experience = this.workExperienceList[i];
          for (const [field, rules] of Object.entries(this.formRules)) {
            if (rules.required && !experience[field]) {
              this.formErrors[`workExperience_${i}_${field}`] = '此字段为必填项';
              isValid = false;
            }
          }
        }
      }
      
      // 验证附件上传
      for (const field of ['idCardFrontUrl', 'idCardBackUrl', 'degreeCertificateUrl', 'professionalCertificateUrl']) {
        if (!this.formData[field]) {
          this.formErrors[field] = '此字段为必填项';
          isValid = false;
        }
      }
      
      return isValid;
    },
    
    // 处理文件上传
    handleFileUpload(field, event) {
      const file = event.target.files[0];
      if (!file) return;
      
      // 检查文件大小（10MB）
      if (file.size > 10 * 1024 * 1024) {
        this.formErrors[field] = '文件大小不能超过10MB';
        return;
      }
      
      // 检查文件类型
      const allowedTypes = ['application/pdf', 'image/png', 'image/jpeg'];
      if (!allowedTypes.includes(file.type)) {
        this.formErrors[field] = '请上传PDF或图片文件';
        return;
      }
      
      this.formErrors[field] = '';
      
      // 读取文件并预览
      const reader = new FileReader();
      reader.onload = (e) => {
        this.formData[field] = e.target.result;
      };
      reader.readAsDataURL(file);
    },
    
    // 获取选项的显示值
    getDisplayValue(field, value) {
      if (value === null || value === undefined) return '未填写'
      if (typeof value === 'boolean') return value ? '是' : '否'
      // 处理专业字段
      if (field.includes('Major')) {
        if (Array.isArray(value)) {
          return value.join('/')
        } else if (typeof value === 'string' && value.includes('/')) {
          return value
        }
      }
      return value
    },
    
    // 模拟提交表单数据到API
    async submitFormData() {
      // 实际项目中替换为真实API调用
      return new Promise((resolve) => {
        setTimeout(() => {
          resolve({ success: true });
        }, 1000);
      });
    },
    
    // 切换标签页
    handleTabClick(tab) {
      if (!this.formData.expertId && tab.name !== 'basicInfo') {
        this.$message.warning('请先保存基本信息')
        this.activeTab = 'basicInfo'
        return
      }
    },
    
    getFileIcon(url) {
      if (!url) return 'el-icon-document';
      const ext = url.toLowerCase();
      if (ext.endsWith('.pdf')) return 'el-icon-document-checked';
      if (ext.endsWith('.png') || ext.endsWith('.jpg') || ext.endsWith('.jpeg')) return 'el-icon-picture';
      return 'el-icon-document';
    },
    
    getFileName(url) {
      if (!url) return '';
      const parts = url.split('/');
      return parts[parts.length - 1];
    },
    
    async previewFile(attachmentType) {
      const fileInfo = this.attachmentFiles[attachmentType];
      if (!fileInfo || !fileInfo.fileId) {
        this.$message.warning('文件未上传');
        return;
      }

      try {
        // 直接使用已经获取到的文件信息
        this.previewUrl = fileInfo.url;
        this.previewFileName = fileInfo.fileName;
        this.previewDialogVisible = true;
      } catch (error) {
        console.error('预览文件失败:', error);
        this.$message.error('预览文件失败');
      }
    },
    
    closePreview() {
      this.previewUrl = '';
      this.previewFileName = '';
      this.previewDialogVisible = false;
    },
    
    deleteFile(attachmentType) {
      // 如果有原有的fileId，标记为已删除
      const currentFileInfo = this.attachmentFiles[attachmentType] || {};
      if (currentFileInfo.fileId) {
        this.$set(this.attachmentFiles, attachmentType, {
          fileId: null,
          fileName: '未上传文件',
          url: null,
          address: null,
          deleted: true, // 标记为已删除
          originalFileId: currentFileInfo.fileId // 保存原始fileId用于后端删除
        });
        this.$message.success('文件已标记为删除，保存后生效');
      } else {
        this.$set(this.attachmentFiles, attachmentType, {
          fileId: null,
          fileName: '未上传文件',
          url: null,
          address: null
        });
      }
      this.formErrors[attachmentType] = '';
    },
    
    // 格式化日期时间
    formatDateTime(datetime) {
      if (!datetime) return '-';
      return datetime.replace(/\..*$/, '').replace('T', ' ');
    },
    
    // 获取附件信息
    async getAttachInfo(expertId) {
      if (!expertId || this.hasLoadedAttachments) {
        return;
      }
      
      try {
        console.log('开始获取专家附件信息, expertId:', expertId);
        const response = await getExpertAttach(expertId);
        
        if (response?.code === 200 && response.data) {
          const attachData = response.data;
          
          // 收集所有需要获取信息的文件ID，使用Map来存储文件ID和对应的类型
          const fileIdMap = new Map();
          
          // 收集所有文件ID和对应的类型
          if (attachData.idCard) fileIdMap.set(attachData.idCard, 'idCard');
          if (attachData.certificate) fileIdMap.set(attachData.certificate, 'certificate');
          if (attachData.qualification) fileIdMap.set(attachData.qualification, 'qualification');
          if (attachData.supportMater) fileIdMap.set(attachData.supportMater, 'supportMater');
          if (attachData.applicationForm) fileIdMap.set(attachData.applicationForm, 'applicationForm');
          
          // 只获取唯一的文件ID
          const uniqueFileIds = Array.from(fileIdMap.keys());
          
          // 一次性获取所有文件信息
          const fileInfos = await Promise.all(
            uniqueFileIds.map(fileId => getFileInfo(fileId))
          );
          
          // 处理每个文件的响应
          fileInfos.forEach((response, index) => {
            const fileId = uniqueFileIds[index];
            const attachType = fileIdMap.get(fileId);
            
            if (response?.code === 200 && response.data) {
              const fileData = response.data;
              this.$set(this.attachmentFiles, attachType, {
                fileId: fileData.fileId,
                fileName: fileData.fileName || '未知文件名',
                url: fileData.address,
                address: fileData.address,
                uploadTime: fileData.uploadTime
              });
            } else {
              this.$set(this.attachmentFiles, attachType, {
                fileId: fileId,
                fileName: getDefaultFileName(attachType),
                url: null,
                address: null
              });
            }
          });
        }
      } catch (error) {
        console.error('获取附件信息失败:', error);
      }
      
      // 设置已加载标志
      this.hasLoadedAttachments = true;
    },

    // 更新附件文件信息
    async updateAttachmentFiles(fileIds) {
      // 创建一个 Set 来存储已经请求过的文件ID
      const requestedFileIds = new Set();
      
      for (const [key, fileId] of Object.entries(fileIds)) {
        if (!fileId || requestedFileIds.has(fileId)) {
          console.log(`${key} 没有文件ID或已经请求过`);
          continue;
        }

        requestedFileIds.add(fileId);

        try {
          console.log(`开始获取 ${key} 的文件信息, fileId:`, fileId);
          const response = await getFileInfo(fileId);
          console.log(`${key} 文件信息响应:`, response);

          if (response?.code === 200 && response.data) {
            const fileData = response.data;
            // 使用 $set 确保响应式更新
            this.$set(this.attachmentFiles, key, {
              fileId: fileData.fileId,
              fileName: fileData.fileName || '未知文件名',
              url: fileData.address,  // 使用address作为文件URL
              address: fileData.address,
              uploadTime: fileData.uploadTime
            });

            // 如果其他附件也使用相同的fileId，直接复用结果
            for (const [otherKey, otherId] of Object.entries(fileIds)) {
              if (otherKey !== key && otherId === fileId) {
                this.$set(this.attachmentFiles, otherKey, {
                  ...this.attachmentFiles[key]
                });
              }
            }
          } else {
            console.warn(`获取 ${key} 文件信息失败:`, response);
            this.$set(this.attachmentFiles, key, {
              fileId: fileId,
              fileName: '获取文件信息失败',
              url: null,
              address: null
            });
          }
        } catch (error) {
          console.error(`获取 ${key} 文件信息失败:`, error);
          this.$set(this.attachmentFiles, key, {
            fileId: fileId,
            fileName: '获取文件信息失败',
            url: null,
            address: null
          });
        }
      }
      
      console.log('所有附件信息更新完成:', this.attachmentFiles);
    },
    
    // 获取附件类型 (使用更完整的版本)
    
    // 处理附件选择
    handleAttachmentUpload(attachmentType, event) {
      console.log('handleAttachmentUpload 被调用，附件类型:', attachmentType);
      const file = event.target.files[0];
      if (!file) {
        console.log('没有选择文件');
        return;
      }
      
      console.log('选择的文件:', file.name, '大小:', file.size, '类型:', file.type);
      
      // 检查文件大小（10MB）
      if (file.size > 10 * 1024 * 1024) {
        this.$message.error('文件大小不能超过10MB');
        return;
      }
      
      // 检查文件类型
      const allowedTypes = ['application/pdf'];
      if (!allowedTypes.includes(file.type)) {
        this.$message.error('请上传PDF格式的文件');
        return;
      }
      
      // 获取文件类型 - 这是关键修复
      const fileType = this.getAttachmentType(attachmentType);
      console.log('转换后的文件类型:', fileType);
      
      // 获取当前文件信息
      const currentFileInfo = this.attachmentFiles[fileType] || {};
      console.log('当前文件信息:', JSON.stringify(currentFileInfo, (key, value) => {
        if (key === 'file') return '[File对象]';
        return value;
      }));
      
      // 保留原有的fileId和其他信息，只更新file和fileName
      this.$set(this.attachmentFiles, fileType, {
        ...currentFileInfo,
        file: file,
        fileName: file.name
      });
      
      console.log('已更新attachmentFiles:', JSON.stringify(this.attachmentFiles[fileType], (key, value) => {
        if (key === 'file') return '[File对象]';
        return value;
      }));
      
      this.$message.success('文件已选择，请点击保存按钮提交');
    },
    
    // 保留旧方法以兼容可能的其他引用
    handleFileUpload(attachmentType, event) {
      console.log('旧的handleFileUpload被调用，转发到handleAttachmentUpload');
      this.handleAttachmentUpload(attachmentType, event);
    },
    
    // 下载文件
    downloadFile(attachmentType) {
      const fileInfo = this.attachmentFiles[attachmentType];
      if (!fileInfo || !fileInfo.fileId) {
        this.$message.warning('文件未上传');
        return;
      }

      try {
        // 创建一个隐藏的a标签来下载文件
        const link = document.createElement('a');
        link.style.display = 'none';
        link.href = fileInfo.url;
        link.setAttribute('download', fileInfo.fileName);
        document.body.appendChild(link);
        link.click();
        document.body.removeChild(link);
      } catch (error) {
        console.error('下载文件失败:', error);
        this.$message.error('下载文件失败');
      }
    },
    getOptionsForField(key) {
      const optionsMap = {
        gender: this.sexs,
        education: this.education,
        title: this.titles,
        politicalStatus: this.politicalStatus
      };
      return optionsMap[key] || [];
    },
    
    // 文件上传前的验证
    beforeUploadimg(file) {
      const isJPG = file.type === 'image/jpeg';
      const isLt4M = file.size / 1024 / 1024 < 4;

      if (!isJPG) {
        this.$message.error('上传头像图片只能是 JPG 格式!');
      }
      if (!isLt4M) {
        this.$message.error('上传头像图片大小不能超过 4MB!');
      }
      return isJPG && isLt4M;
    },

    // 处理头像上传成功
    handleAvatarSuccess(res, file) {
      this.formData.photoUrl = URL.createObjectURL(file.raw);
    },

    // 处理文件变更
    handleChange(file) {
      const reader = new FileReader();
      reader.readAsDataURL(file.raw);
      reader.onload = () => {
        this.formData.photoUrl = reader.result;
      };
    },
    // 处理专业选择变化
    handleMajorChange(index) {
      const majors = [
        this.formData.primaryMajor,
        this.formData.secondMajor,
        this.formData.thirdMajor,
        this.formData.fourthMajor,
        this.formData.fifthMajor
      ].filter(major => {
        // 过滤掉空值和"无"选项
        if (!major) return false;
        if (Array.isArray(major) && major.length === 1 && major[0] === '无') return false;
        return true;
      });

      // 重置错误标记
      this.showMajorError = [0, 0, 0, 0, 0];

      // 检查重复
      majors.forEach((major, i) => {
        if (!major) return;
        const count = majors.filter(m => m && m[0] === major[0]).length;
        if (count > 1) {
          // 找到原始索引并设置错误
          const originalIndex = [
            this.formData.primaryMajor,
            this.formData.secondMajor,
            this.formData.thirdMajor,
            this.formData.fourthMajor,
            this.formData.fifthMajor
          ].findIndex(m => m && m[0] === major[0]);
          if (originalIndex !== -1) {
            this.showMajorError[originalIndex] = 1;
          }
        }
      });
    },
    // 工作经历相关方法
    handleAddWorkExperience() {
      this.workExperienceList.push({
        orgName: '',
        startDate: '',
        endDate: '',
        jobTitle: '',
        jobDuty: ''
      });
      this.editingIndex = this.workExperienceList.length - 1;
    },

    handleEditWorkExperience(index, row) {
      this.editingIndex = index;
    },

    handleSaveWorkExperience(index, row) {
      if (!row.orgName || !row.startDate || !row.jobTitle || !row.jobDuty) {
        this.$message.error('请填写完整信息');
        return;
      }
      this.editingIndex = -1;
    },

    handleDeleteWorkExperience(index) {
      this.$confirm('确认删除该工作经历?', '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning'
      }).then(() => {
        this.workExperienceList.splice(index, 1);
        this.$message.success('删除成功');
      }).catch(() => {});
    },

    // 社会兼职相关方法
        handleAddSocialExperience() {
    this.socialExperienceList.push({
      id: '',
      expertId: this.expertId,
      partTimeUnit: '', // 使用 partTimeUnit 而不是 orgName
      startTime: '',
      endTime: '',
      partTimeIdentity: '',
      createTime: '',
      updateTime: ''
    });
    this.socialEditingIndex = this.socialExperienceList.length - 1;
  },

    handleEditSocialExperience(index, row) {
      this.socialEditingIndex = index;
    },

    handleSaveSocialExperience(index, row) {
      if (!row.orgName || !row.startDate || !row.role) {
        this.$message.error('请填写完整信息');
        return;
      }
      this.socialEditingIndex = -1;
    },

    handleDeleteSocialExperience(index) {
      this.$confirm('确认删除该兼职经历?', '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning'
      }).then(() => {
        this.socialExperienceList.splice(index, 1);
        this.$message.success('删除成功');
      }).catch(() => {});
    },

    handleCancelEdit() {
      this.editingIndex = -1;
    },

    // 基本信息相关方法
    formatDate(date) {
      const formattedDate = new Date(date);
      const year = formattedDate.getFullYear().toString();
      const month = String(formattedDate.getMonth() + 1).padStart(2, '0');
      const day = String(formattedDate.getDate()).padStart(2, '0');
      return `${year}-${month}-${day}`;
    },

    loadBasicInfo() {
      if (this.expertId) {
        http.get(`/admin/expertBasicInfo/get/${this.expertId}`).then(response => {
          if (response.data.code === 200) {
            const data = response.data.data;
            // 处理专业字段
            ['primaryMajor', 'secondMajor', 'thirdMajor', 'fourthMajor', 'fifthMajor'].forEach(field => {
              if (data[field]) {
                data[field] = data[field].split('/');
              }
            });
            
            // 处理籍贯
            if (data.nativePlace) {
              data.nativePlace = data.nativePlace.split('/');
            }
            
            this.formData = data;
          }
        }).catch(error => {
          console.error('获取基本信息失败:', error);
        });
      }
    },

    // 加载工作经历数据
    async loadWorkExperience() {
      try {
        if (!this.formData.expertId) return;
        const response = await http.get(`/admin/workExperience/list/${this.formData.expertId}`);
        if (response.data.code === 200) {
          this.workExperienceList = response.data.data || [];
        }
      } catch (error) {
        console.error('加载工作经历失败:', error);
      }
    },

    // 加载社会兼职数据
    async loadSocialExperience() {
      try {
        if (!this.formData.expertId) return;
        const response = await http.get(`/admin/expertSocialPart/get/${this.formData.expertId}`);
        if (response.data.code === 200) {
          this.socialExperienceList = response.data.data.map(item => ({
            id: item.id || '',
            expertId: item.expertId,
            orgName: item.orgName || '',
            startDate: item.startDate || '',
            endDate: item.endDate || '',
            role: item.role || '',
            createTime: item.createTime || '',
            updateTime: item.updateTime || ''
          })) || [];
        }
      } catch (error) {
        console.error('加载社会兼职失败:', error);
      }
    },

    // 加载附件数据
    async loadAttachments() {
      try {
        if (!this.formData.expertId) return;
        const response = await http.get(`/admin/attachments/list/${this.formData.expertId}`);
        if (response.data.code === 200) {
          this.attachmentsList = response.data.data || [];
        }
      } catch (error) {
        console.error('加载附件失败:', error);
      }
    },

    // 工作履历编辑控制
    handleEditWorkExperienceInfo() {
      this.isWorkExperienceReadOnly = false;
    },

    async handleSaveWorkExperienceInfo() {
      try {
        if (!this.expertId) {
          this.$message.warning('请先保存基本信息');
          return;
        }

        // 保存工作经历
        const workExperienceData = this.workExperienceList.map(item => ({
          id: item.id || '',
          expertId: this.expertId,
          orgName: item.workUnit || item.orgName || '', // 优先使用 workUnit
          startDate: item.startTime || item.startDate || '',
          endDate: item.endTime || item.endDate || '',
          title: item.jobTitle || item.title || '',
          position: item.jobDuty || item.position || '',
          createTime: item.createTime || '',
          updateTime: item.updateTime || ''
        }));
        
        // 调用API保存数据
        const workResponse = await addOrUpdateWorkExperience(workExperienceData);
        
        if (workResponse.code === 200) {
          this.$message.success('保存成功');
          
          // 更新工作经历列表的ID
          if (workResponse.data && Array.isArray(workResponse.data)) {
            this.workExperienceList = this.workExperienceList.map((item, index) => ({
              ...item,
              id: workResponse.data[index]
            }));
          }

          // 切换为只读模式
          this.isWorkExperienceReadOnly = true;
        } else {
          this.$message.error('保存失败：' + workResponse.message);
        }
      } catch (error) {
        console.error('保存失败:', error);
        this.$message.error('保存失败，请稍后重试');
      }
    },

    // 附件上传编辑控制
    handleEditAttachmentInfo() {
      this.isAttachmentReadOnly = false;
    },

    async handleSaveAttachmentInfo() {
      console.log('开始保存附件信息，expertId:', this.expertId);
      
      if (!this.expertId) {
        this.$message.warning('请先保存基本信息');
        return;
      }

      // 创建 FormData 对象
      const formData = new FormData();
      
      // 添加专家ID到FormData
      formData.append('expertId', this.expertId);
      
      // 定义必需的附件类型
      const requiredTypes = ['idCard', 'certificate', 'qualification', 'supportMater', 'applicationForm'];
      
      // 检查是否有任何文件（新文件或已有文件）
      let hasAnyFiles = false;
      
      requiredTypes.forEach(type => {
        const fileInfo = this.attachmentFiles[type];
        console.log(`检查附件类型 ${type}:`, fileInfo ? (fileInfo.file ? '有新文件' : (fileInfo.fileId ? '有已有文件' : '无文件')) : '无信息');
        
        // 如果有新文件或已有文件，标记为有文件
        if (fileInfo && (fileInfo.file instanceof File || fileInfo.fileId)) {
          hasAnyFiles = true;
        }
      });
      
      if (!hasAnyFiles) {
        this.$message.warning('没有任何附件可保存');
        return;
      }

      // 添加所有文件到 FormData
      requiredTypes.forEach(type => {
        const fileInfo = this.attachmentFiles[type];
        
        if (fileInfo && fileInfo.file instanceof File) {
          // 如果是新选择的文件，添加到FormData
          console.log(`添加新文件到FormData: ${type}, 文件名: ${fileInfo.fileName}`);
          formData.append(type, fileInfo.file);
        } else if (fileInfo && fileInfo.fileId) {
          // 如果是已存在的文件，添加一个空文件
          // 后端会检测到文件为空，保留原有文件
          console.log(`添加空文件到FormData以保留已有文件: ${type}, 文件ID: ${fileInfo.fileId}`);
          formData.append(type, new File([], 'empty.pdf', { type: 'application/pdf' }));
        } else if (fileInfo && fileInfo.deleted === true) {
          // 如果文件被标记为删除，添加一个特殊标记
          console.log(`添加删除标记到FormData: ${type}, 原始文件ID: ${fileInfo.originalFileId}`);
          // 对于删除的文件，我们发送一个特殊的空文件
          // 这样后端会将其视为一个新文件，并替换原有文件
          // 但由于文件内容为空，后端会将其视为一个删除请求
          const emptyFile = new File([], 'deleted.pdf', { type: 'application/pdf' });
          formData.append(type, emptyFile);
        } else {
          // 如果没有文件，添加一个空文件
          console.log(`添加空文件到FormData: ${type}`);
          formData.append(type, new File([], 'empty.pdf', { type: 'application/pdf' }));
        }
      });

      // 检查FormData内容
      console.log('准备上传附件，已创建FormData对象');
      for (const pair of formData.entries()) {
        console.log(`FormData包含: ${pair[0]} = ${pair[1] instanceof File ? `[File: ${pair[1].name}]` : pair[1]}`);
      }
      
      // 显示上传中提示
      const loading = this.$loading({
        lock: true,
        text: '附件上传中...',
        spinner: 'el-icon-loading',
        background: 'rgba(0, 0, 0, 0.7)'
      });

      try {
        // 调用API保存附件数据
        console.log(`调用uploadExpertAttach API, expertId: ${this.expertId}`);
        console.log('FormData内容总结:');
        requiredTypes.forEach(type => {
          const fileInfo = this.attachmentFiles[type];
          if (fileInfo && fileInfo.file instanceof File) {
            console.log(`- ${type}: 上传新文件 "${fileInfo.fileName}"`);
          } else if (fileInfo && fileInfo.fileId) {
            console.log(`- ${type}: 保留原有文件 (ID: ${fileInfo.fileId})`);
          } else if (fileInfo && fileInfo.deleted === true) {
            console.log(`- ${type}: 删除文件 (原始ID: ${fileInfo.originalFileId})`);
          } else {
            console.log(`- ${type}: 无文件`);
          }
        });
        
        const response = await uploadExpertAttach(this.expertId, formData);
        
        console.log('附件上传响应:', response);
        
        if (response.code === 200) {
          this.$message.success('附件保存成功');
          this.isAttachmentReadOnly = true;
          // 清除所有文件的file属性，以便重新加载
          requiredTypes.forEach(type => {
            if (this.attachmentFiles[type] && this.attachmentFiles[type].file) {
              this.$set(this.attachmentFiles[type], 'file', null);
            }
          });
          // 强制重置hasLoadedAttachments标志，确保重新加载
          this.hasLoadedAttachments = false;
          // 重新加载附件数据，强制刷新
          await this.getAttachInfo(this.expertId, true);
        } else if (response.code === 201) {
          // 处理特殊的201状态码
          console.warn('服务器返回201状态码:', response.message);
          this.$message.warning(response.message || '部分附件保存成功');
          this.isAttachmentReadOnly = true;
          // 清除所有文件的file属性，以便重新加载
          requiredTypes.forEach(type => {
            if (this.attachmentFiles[type] && this.attachmentFiles[type].file) {
              this.$set(this.attachmentFiles[type], 'file', null);
            }
          });
          // 强制重置hasLoadedAttachments标志，确保重新加载
          this.hasLoadedAttachments = false;
          // 重新加载附件数据
          await this.getAttachInfo(this.expertId, true);
        } else {
          console.error('服务器返回错误:', response);
          throw new Error(response.message || '保存失败');
        }
      } catch (error) {
        console.error('保存附件失败:', error);
        
        // 尝试提取更详细的错误信息
        let errorMessage = '保存失败，请重试';
        if (error.message) {
          errorMessage = error.message;
        } else if (error.response && error.response.data) {
          // 尝试从响应中提取错误信息
          const responseData = error.response.data;
          if (typeof responseData === 'string') {
            errorMessage = responseData;
          } else if (responseData.message) {
            errorMessage = responseData.message;
          } else if (responseData.error) {
            errorMessage = responseData.error;
          }
        }
        
        this.$message.error(errorMessage);
      } finally {
        loading.close();
      }
    },
    
    // 获取附件类型的显示名称
    getAttachmentDisplayName(type) {
      const displayNames = {
        'idCard': '身份证',
        'certificate': '最高学历(学位)证书及技术职称',
        'qualification': '职业资格证书',
        'supportMater': '研究成果及工作成就材料',
        'applicationForm': '专家入库申请表'
      };
      return displayNames[type] || type;
    },

    async handleSaveOtherInfo() {
      try {
        if (!this.expertId) {
          this.$message.warning('请先保存基本信息');
          return;
        }

        const otherInfoData = {
          id: this.otherInfoForm.id || '',
          expertId: this.expertId,
          researchResults: this.otherInfoForm.researchResults || '',
          projectConsultation: this.otherInfoForm.projectConsultation || '',
          createTime: this.otherInfoForm.createTime || '',
          updateTime: this.otherInfoForm.updateTime || ''
        };

        console.log('保存其他信息数据:', otherInfoData);
        const response = await this.$http.post('/admin/expertOtherInfo/addOrUpdate', otherInfoData);
        
        if (response.code === 200) {
          this.$message.success('其他信息保存成功');
          this.otherInfoForm.id = response.data.id;
          this.isOtherInfoReadOnly = true;
        } else {
          this.$message.error(response.message || '保存失败');
        }
      } catch (error) {
        console.error('保存其他信息失败:', error);
        this.$message.error('保存失败');
      }
    },

    handleCancelOtherInfo() {
      this.isOtherInfoReadOnly = true;
      if (!this.otherInfoForm.id) {
        this.researchResults = '';
        this.projectMatters = '';
      }
    },

    async loadOtherInfo() {
      try {
        if (!this.expertId) return;
        
        const response = await this.$http.get(`/admin/expertOtherInfo/get/${this.expertId}`);
        console.log('加载其他信息响应:', response);
        if (response.code === 200 && response.data) {
          this.otherInfoForm = response.data;
          this.otherInfoForm = response.data;
          console.log('设置其他信息:', {
            researchAchievements: this.researchAchievements,
            projectMatters: this.projectMatters
          });
        }
      } catch (error) {
        console.error('加载其他信息失败:', error);
      }
    },

    handleEditOtherInfo() {
      this.isOtherInfoReadOnly = false;
    },

    handleEditSocialExperienceInfo() {
      this.isSocialExperienceReadOnly = false;
    },

    async handleSaveSocialExperienceInfo() {
      try {
        if (!this.expertId) {
          this.$message.warning('请先保存基本信息');
          return;
        }

        // 保存社会兼职
        const socialPartData = this.socialExperienceList.map(item => ({
          id: item.id || '',
          expertId: this.expertId,
          orgName: item.orgName || '',
          startDate: item.startDate || '',
          endDate: item.endDate || '',
          role: item.role || ''
        }));

        const response = await addOrUpdateSocialPart(socialPartData);
        
        if (response.code === 200) {
          this.$message.success('保存成功');
          
          // 更新社会兼职列表的ID
          if (response.data && Array.isArray(response.data)) {
            this.socialExperienceList = this.socialExperienceList.map((item, index) => ({
              ...item,
              id: response.data[index]
            }));
          }

          // 切换为只读模式
          this.isSocialExperienceReadOnly = true;
          this.socialEditingIndex = -1;
        } else {
          this.$message.error('保存失败：' + response.message);
        }
      } catch (error) {
        console.error('保存失败:', error);
        this.$message.error('保存失败，请稍后重试');
      }
    },

    handleCancelSocialExperienceInfo() {
      this.isSocialExperienceReadOnly = true;
      this.socialEditingIndex = -1;
      this.loadSocialExperience(); // 重新加载数据
    },

    handleEditSocialExperience(index, row) {
      this.socialEditingIndex = index;
      this.tempSocialExperience = { ...row };
    },

    handleCancelSocialEdit() {
      this.socialEditingIndex = -1;
      this.loadSocialExperience(); // 重新加载数据
    },

    // 将布尔值转换为显示值
    convertToDisplayValue(value) {
      if (value === true || value === 'true' || value === '是') return '是';
      if (value === false || value === 'false' || value === '否') return '否';
      return '';
    },

    // 将显示值转换回布尔值（用于保存时）
    convertToBoolean(value) {
      if (value === '是' || value === true) return true;
      if (value === '否' || value === false) return false;
      return null;
    },
    // 取消编辑，恢复原始数据
    handleCancelBasicInfo() {
      this.isBasicInfoReadOnly = true;
      if (this.originalFormData) {
        this.formData = JSON.parse(JSON.stringify(this.originalFormData));
      }
    },
    getWorkExperience(expertId) {
      console.log('获取工作经历，专家ID:', expertId);
      this.$http.get(`/admin/expertWorkExper/get/${expertId}`).then(response => {
        console.log('工作经历数据:', response.data);
        if (response && response.data) {
          // 映射后端字段到前端字段
          const mappedExperience = response.data.map(item => ({
            orgName: item.orgName || '',
            startDate: item.startDate || '',
            endDate: item.endDate || '',
            title: item.title || '',
            position: item.position || '',
            id: item.id,
            expertId: item.expertId
          }));
          console.log('映射后的工作经历:', mappedExperience);
          this.$set(this.row, 'workExperience', mappedExperience);
        }
      }).catch(error => {
        console.error('获取工作经历失败:', error);
        this.$message.error('获取工作经历失败');
      });
    },
    // 获取社会兼、聘职情况
    getSocialPart(expertId) {
      console.log('获取社会兼职情况，专家ID:', expertId);
      this.$http.get(`/admin/expertSocialPart/get/${expertId}`).then(response => {
        console.log('社会兼职数据:', response.data);
        if (response && response.data) {
          // 映射后端字段到前端字段
          const mappedSocialPart = response.data.map(item => ({
            orgName: item.orgName || '',
            startDate: item.startDate || '',
            endDate: item.endDate || '',
            role: item.role || '',
            id: item.id,
            expertId: item.expertId
          }));
          console.log('映射后的社会兼职:', mappedSocialPart);
          this.$set(this.row, 'socialExperience', mappedSocialPart);
        }
      }).catch(error => {
        console.error('获取社会兼职情况失败:', error);
        this.$message.error('获取社会兼职情况失败');
      });
    },
    // 处理文件上传
    handleFileChange(file, type) {
      this.uploadFiles[type] = file.raw
    },

    // 保存附件
    async saveAttachments() {
      const formData = new FormData()
      
      // 添加所有文件到 FormData
      Object.keys(this.uploadFiles).forEach(key => {
        if (this.uploadFiles[key]) {
          formData.append(key, this.uploadFiles[key])
        }
      })

      try {
        await uploadExpertAttach(this.expertId, formData)
        this.$message.success('附件上传成功')
        // 重置上传文件
        Object.keys(this.uploadFiles).forEach(key => {
          this.uploadFiles[key] = null
        })
      } catch (error) {
        this.$message.error('附件上传失败')
      }
    },

    // 获取专家附件信息
    async getExpertAttachments() {
      try {
        const response = await getExpertAttach(this.expertId)
        if (response?.code === 200 && response.data) {
          const attachData = response.data
          
          // 更新附件信息
          this.attachments = {
            idCard: attachData.idCard || null,
            certificate: attachData.certificate || null,
            qualification: attachData.qualification || null,
            supportMater: attachData.supportMater || null,
            applicationForm: attachData.applicationForm || null
          }

          // 获取每个文件的详细信息
          for (const [key, fileId] of Object.entries(this.attachments)) {
            if (fileId) {
              try {
                const fileResponse = await getFileInfo(fileId)
                if (fileResponse?.code === 200 && fileResponse.data) {
                  const fileData = fileResponse.data
                  this.attachments[key] = {
                    fileId: fileData.fileId,
                    fileName: fileData.fileName || '未知文件名',
                    address: fileData.address
                  }
                }
              } catch (error) {
                console.error(`获取文件 ${fileId} 信息失败:`, error)
              }
            }
          }
        }
      } catch (error) {
        this.$message.error('获取附件信息失败')
        console.error('获取附件信息失败:', error)
      }
    },

    // 获取附件类型
    getAttachmentType(key) {
      const mapping = {
        'idCardFrontUrl': 'idCard',                    // 身份证
        'idCardBackUrl': 'certificate',                // 最高学历(学位)证书及技术职称
        'degreeCertificateUrl': 'qualification',       // 职业资格
        'professionalCertificateUrl': 'supportMater',  // 证明材料
        'otherDocumentsUrl': 'applicationForm'         // 专家入库申请表
      };
      return mapping[key] || key;
    },

    // 获取文件图标
    getFileIcon(fileName) {
      if (!fileName) return 'el-icon-document';
      const ext = fileName.toLowerCase();
      if (ext.endsWith('.pdf')) return 'el-icon-document-checked';
      if (ext.endsWith('.jpg') || ext.endsWith('.jpeg') || ext.endsWith('.png')) return 'el-icon-picture';
      return 'el-icon-document';
    },
    
    // 根据附件类型获取默认文件名
    getDefaultFileName(attachType) {
      // 根据附件类型设置有意义的默认文件名
      switch (attachType) {
        case 'idCard':
          return '身份证.pdf';
        case 'certificate':
          return '学历证书.pdf';
        case 'qualification':
          return '职业资格证书.pdf';
        case 'supportMater':
          return '研究成果材料.pdf';
        case 'applicationForm':
          return '专家入库申请表.pdf';
        default:
          return '附件.pdf';
      }
    },

    // 获取附件信息
    async getAttachInfo(expertId) {
      if (!expertId || this.hasLoadedAttachments) {
        return;
      }
      
      try {
        console.log('开始获取专家附件信息, expertId:', expertId);
        const response = await getAttachmentsByExpertId(expertId);
        console.log('获取专家附件信息响应:', response);
        
        if (response?.code === 200 && response.data) {
          const attachData = response.data;
          console.log('获取到的附件数据:', attachData);
          
          // 收集所有需要获取信息的文件ID，使用Map来存储文件ID和对应的类型
          const fileIdMap = new Map();
          
          // 收集所有文件ID和对应的类型
          if (attachData.idCard) {
            console.log('身份证文件ID:', attachData.idCard);
            fileIdMap.set(attachData.idCard, 'idCard');
          }
          if (attachData.certificate) {
            console.log('证书文件ID:', attachData.certificate);
            fileIdMap.set(attachData.certificate, 'certificate');
          }
          if (attachData.qualification) {
            console.log('资格文件ID:', attachData.qualification);
            fileIdMap.set(attachData.qualification, 'qualification');
          }
          if (attachData.supportMater) {
            console.log('支持材料文件ID:', attachData.supportMater);
            fileIdMap.set(attachData.supportMater, 'supportMater');
          }
          if (attachData.applicationForm) {
            console.log('申请表文件ID:', attachData.applicationForm);
            fileIdMap.set(attachData.applicationForm, 'applicationForm');
          }
          
          // 获取唯一的文件ID列表
          const uniqueFileIds = Array.from(fileIdMap.keys());
          console.log('需要获取信息的唯一文件ID列表:', uniqueFileIds);
          
          // 逐个获取文件信息
          for (const fileId of uniqueFileIds) {
            const attachType = fileIdMap.get(fileId);
            console.log(`正在获取文件信息, ID: ${fileId}, 类型: ${attachType}`);
            
            try {
              console.log(`开始调用getFileInfo API, 文件ID: ${fileId}`);
              const fileResponse = await getFileInfo(fileId);
              console.log(`文件 ${fileId} 的API响应:`, fileResponse);
              
              // 检查API响应格式
              if (fileResponse?.code === 200 && fileResponse.data) {
                // 检查文件数据
                const fileData = fileResponse.data;
                console.log(`文件 ${fileId} 的数据:`, fileData);
                
                if (fileData && fileData.fileId && fileData.address) {
                  // 检查是否已经有新选择的文件
                  const currentFileInfo = this.attachmentFiles[attachType] || {};
                  
                  // 如果已经有新选择的文件，不要覆盖它
                  if (currentFileInfo.file instanceof File) {
                    console.log(`${attachType} 已有新选择的文件，保留新文件信息`);
                    // 保留file字段，更新其他信息
                    this.$set(this.attachmentFiles, attachType, {
                      ...currentFileInfo,
                      fileId: fileData.fileId,
                      address: fileData.address,
                      url: fileData.address
                    });
                  } else {
                    // 没有新选择的文件，更新文件信息
                    const updateObj = {
                      fileId: fileData.fileId,
                      fileName: fileData.fileName || '未知文件名',
                      address: fileData.address,
                      url: fileData.address
                    };
                    
                    console.log(`准备更新 ${attachType} 的文件信息:`, updateObj);
                    this.$set(this.attachmentFiles, attachType, updateObj);
                  }
                  
                  console.log(`已更新 ${attachType} 的文件信息，当前值:`, 
                    JSON.stringify(this.attachmentFiles[attachType], (key, value) => {
                      if (key === 'file') return '[File对象]';
                      return value;
                    })
                  );
                } else {
                  // 文件数据不完整
                  console.warn(`文件 ${fileId} 数据不完整:`, fileData);
                  
                  // 检查是否已经有新选择的文件
                  const currentFileInfo = this.attachmentFiles[attachType] || {};
                  
                  // 如果已经有新选择的文件，不要覆盖它
                  if (currentFileInfo.file instanceof File) {
                    console.log(`${attachType} 已有新选择的文件，保留新文件信息`);
                    // 保留file字段，更新其他信息
                    this.$set(this.attachmentFiles, attachType, {
                      ...currentFileInfo,
                      fileId: fileId,
                      address: fileData.address || null,
                      url: fileData.address || null
                    });
                  } else {
                    // 没有新选择的文件，设置默认值
                    const updateObj = {
                      fileId: fileId,
                      fileName: this.getDefaultFileName(attachType),
                      address: fileData.address || null,
                      url: fileData.address || null
                    };
                    console.log(`由于数据不完整，将设置 ${attachType} 的部分默认值:`, updateObj);
                    this.$set(this.attachmentFiles, attachType, updateObj);
                  }
                }
              } else {
                // API响应无效
                console.warn(`文件 ${fileId} API响应无效:`, fileResponse);
                
                // 检查是否已经有新选择的文件
                const currentFileInfo = this.attachmentFiles[attachType] || {};
                
                // 如果已经有新选择的文件，不要覆盖它
                if (currentFileInfo.file instanceof File) {
                  console.log(`${attachType} 已有新选择的文件，保留新文件信息`);
                  // 保留file字段，更新其他信息
                  this.$set(this.attachmentFiles, attachType, {
                    ...currentFileInfo,
                    fileId: fileId
                  });
                } else {
                  // 没有新选择的文件，设置默认值
                  const updateObj = {
                    fileId: fileId,
                    fileName: this.getDefaultFileName(attachType),
                    address: null,
                    url: null
                  };
                  console.log(`由于API响应无效，将设置 ${attachType} 的默认值:`, updateObj);
                  this.$set(this.attachmentFiles, attachType, updateObj);
                }
              }
            } catch (error) {
              // 发生异常
              console.error(`获取文件 ${fileId} 信息失败:`, error);
              
              // 检查是否已经有新选择的文件
              const currentFileInfo = this.attachmentFiles[attachType] || {};
              
              // 如果已经有新选择的文件，不要覆盖它
              if (currentFileInfo.file instanceof File) {
                console.log(`${attachType} 已有新选择的文件，保留新文件信息`);
                // 保留file字段，更新其他信息
                this.$set(this.attachmentFiles, attachType, {
                  ...currentFileInfo,
                  fileId: fileId
                });
              } else {
                // 没有新选择的文件，设置默认值
                const updateObj = {
                  fileId: fileId,
                  fileName: this.getDefaultFileName(attachType),
                  address: null,
                  url: null
                };
                console.log(`由于错误，将设置 ${attachType} 的默认值:`, updateObj);
                this.$set(this.attachmentFiles, attachType, updateObj);
              }
            }
          }
        }
      } catch (error) {
        console.error('获取附件信息失败:', error);
      }
    },

    // 下载文件
    async downloadFile(attachmentType) {
      try {
        console.log(`开始处理文件下载请求，类型: ${attachmentType}`);
        
        // 获取文件信息
        const fileInfo = this.attachmentFiles[attachmentType];
        console.log(`获取到的文件信息:`, fileInfo);
        
        if (!fileInfo) {
          throw new Error('文件信息不存在');
        }
        
        if (!fileInfo.fileId) {
          this.$message.warning('文件未上传');
          return;
        }

        // 尝试获取文件URL
        let fileUrl = fileInfo.address || fileInfo.url;
        console.log(`原始文件URL: ${fileUrl}`);
        
        if (!fileUrl) {
          // 如果文件地址无效，直接通过fileId获取文件信息
          try {
            console.log(`文件地址无效，直接通过fileId获取文件信息: ${fileInfo.fileId}`);
            const fileResponse = await getFileInfo(fileInfo.fileId);
            console.log(`获取到的文件信息:`, fileResponse);
            
            if (fileResponse && fileResponse.address) {
              fileUrl = fileResponse.address;
            } else if (fileResponse?.code === 200 && fileResponse.data && fileResponse.data.address) {
              fileUrl = fileResponse.data.address;
            } else {
              throw new Error('无法获取文件地址');
            }
            
            console.log(`成功获取文件地址: ${fileUrl}`);
          } catch (error) {
            console.error('获取文件地址失败:', error);
            throw new Error('无法获取文件地址，下载失败');
          }
        }

        // 处理文件URL
        console.log('处理前的文件URL:', fileUrl);
        
        // 确保fileUrl不为空
        if (!fileUrl) {
          throw new Error('文件URL为空');
        }
        
        // 创建下载链接
        const link = document.createElement('a');
        
        // 判断fileUrl是否是完整URL
        if (fileUrl.startsWith('http')) {
          link.href = fileUrl;
          console.log('使用完整URL下载:', fileUrl);
        } else {
          // 如果不是完整URL，需要进行处理
          // 移除开头的斜杠
          if (fileUrl.startsWith('/')) {
            fileUrl = fileUrl.substring(1);
          }
          
          console.log('处理后的文件URL:', fileUrl);
          
          // 使用downloadFile函数下载
          console.log('准备调用downloadFile API, 参数:', fileUrl);
          try {
            const response = await downloadFile(fileUrl);
            console.log('下载响应类型:', response.type, '大小:', response.size);
            
            if (!response || response.size === 0) {
              throw new Error('下载的文件内容为空');
            }
            
            // 检查是否返回了JSON（可能是错误信息）
            if (response.type && response.type.includes('application/json')) {
              // 读取JSON内容
              const reader = new FileReader();
              const jsonContent = await new Promise((resolve, reject) => {
                reader.onload = () => resolve(reader.result);
                reader.onerror = () => reject(new Error('无法读取响应内容'));
                reader.readAsText(response);
              });
              
              console.log('服务器返回JSON:', jsonContent);
              
              try {
                const errorData = JSON.parse(jsonContent);
                console.error('服务器返回错误:', errorData);
                
                if (errorData.message) {
                  throw new Error(errorData.message);
                } else if (errorData.msg) {
                  throw new Error(errorData.msg);
                } else if (errorData.error) {
                  throw new Error(errorData.error);
                } else {
                  throw new Error('服务器返回错误信息');
                }
              } catch (jsonError) {
                console.error('解析JSON错误:', jsonError);
                throw new Error('服务器返回了非文件内容: ' + jsonContent.substring(0, 100));
              }
            }
            
            // 创建blob URL
            link.href = URL.createObjectURL(response);
          } catch (error) {
            console.error('下载文件失败:', error);
            throw new Error('下载文件失败: ' + error.message);
          }
        }
        
        // 设置下载文件名 - 确保使用正确的文件名
        if (fileInfo.fileName && fileInfo.fileName !== '获取文件信息失败') {
          link.download = fileInfo.fileName;
        } else {
          // 如果文件名无效，使用附件类型对应的默认文件名
          link.download = this.getDefaultFileName(attachmentType);
        }
        link.style.display = 'none';
        
        // 添加到文档并触发点击
        document.body.appendChild(link);
        link.click();
        
        // 清理
        setTimeout(() => {
          document.body.removeChild(link);
          if (link.href.startsWith('blob:')) {
            URL.revokeObjectURL(link.href);
          }
        }, 100);
        
        this.$message.success('文件下载成功');
      } catch (error) {
        console.error('下载文件失败:', error);
        this.$message.error(error.message || '下载文件失败，请重试');
      }
    },

    // 获取专家图像信息
    async getExpertImage() {
      try {
        const id = this.$route.params.id
        if (id) {
          const basicInfo = await getExpertBasicInfo(id)
          if (basicInfo.data) {
            this.expertId = basicInfo.data.expertId
            // 获取专家附件信息
            const attachInfo = await getAttachmentsByExpertId(this.expertId)
            if (attachInfo.data && attachInfo.data.photoUrl) {
              this.formData.photoUrl = attachInfo.data.photoUrl
            }
          }
        }
      } catch (error) {
        console.error('获取专家图像失败:', error)
        this.$message.error('获取专家图像失败')
      }
    },

    // 处理文件上传
    async handleFileUpload(key, event) {
      const file = event.target.files[0]
      if (!file) return

      // 验证文件类型
      if (!file.type.startsWith('image/')) {
        this.formErrors[key] = '请上传图片文件'
        return
      }

      // 验证文件大小（2MB = 2 * 1024 * 1024 bytes）
      if (file.size > 2 * 1024 * 1024) {
        this.formErrors[key] = '文件大小不能超过2MB'
        return
      }

      try {
        // 先创建本地预览
        const reader = new FileReader()
        reader.onload = async (e) => {
          try {
            // 获取base64数据
            const base64Data = e.target.result.split(',')[1]
            
            // 创建 FormData 对象
            const formData = new FormData()
            formData.append('file', file)
            formData.append('expertId', this.expertId)
            formData.append('type', 'photo')

            // 上传文件
            const response = await uploadImage(formData)
            if (response.code === 200 && response.data) {
              // 保存base64数据
              this.formData[key] = base64Data
              
              // 创建专家附件信息
              const attachFormData = new FormData()
              attachFormData.append('photoUrl', base64Data)
              
              // 暂存图片数据，在保存基本信息时一起上传
              // 不在这里调用uploadExpertAttach，避免出现错误提示
              this.$message.success('图片已选择，将在保存时上传')
            } else {
              throw new Error('图片上传失败')
            }
          } catch (error) {
            console.error('图片上传失败:', error)
            this.formErrors[key] = '图片上传失败'
            this.$message.error(error.message || '图片上传失败')
          }
        }

        reader.onerror = () => {
          this.formErrors[key] = '图片读取失败'
          this.$message.error('图片读取失败')
        }

        // 读取文件为 base64
        reader.readAsDataURL(file)
      } catch (error) {
        console.error('图片处理失败:', error)
        this.formErrors[key] = '图片处理失败'
        this.$message.error('图片处理失败')
      }
    },

    // 新增加载照片数据的方法
    async loadPhotoData(data) {
      try {
        let photoUrl = '';
        
        // 首先尝试从传入的数据中获取照片URL
        if (data.photoUrl) {
          console.log('原始photoUrl:', data.photoUrl);
          // 如果已经是完整的data:image URL，直接使用
          if (data.photoUrl.startsWith('data:image')) {
            photoUrl = data.photoUrl;
          } else {
            // 处理base64数据
            const base64Data = data.photoUrl.includes(',') ? data.photoUrl.split(',')[1] : data.photoUrl;
            if (base64Data && base64Data !== 'undefined') {
              photoUrl = `data:image/jpeg;base64,${base64Data}`;
            }
          }
        }
        
        // 如果没有获取到照片URL，尝试从专家附件信息获取
        if (!photoUrl) {
          console.log('从附件信息获取照片, expertId:', this.expertId);
          const attachResponse = await getExpertAttach(this.expertId);
          console.log('附件信息响应:', attachResponse);
          
          if (attachResponse?.data && attachResponse.data.photoUrl) {
            const attachPhotoUrl = attachResponse.data.photoUrl;
            // 如果已经是完整的data:image URL，直接使用
            if (attachPhotoUrl.startsWith('data:image')) {
              photoUrl = attachPhotoUrl;
            } else {
              // 处理base64数据
              const base64Data = attachPhotoUrl.includes(',') ? attachPhotoUrl.split(',')[1] : attachPhotoUrl;
              if (base64Data && base64Data !== 'undefined') {
                photoUrl = `data:image/jpeg;base64,${base64Data}`;
              }
            }
          }
        }
        
        console.log('最终photoUrl:', photoUrl);
        
        // 设置照片URL和预览
        if (photoUrl) {
          this.formData.photoUrl = photoUrl;
          this.formData._photoPreview = photoUrl;
          console.log('设置照片URL成功');
        } else {
          this.formData.photoUrl = '';
          this.formData._photoPreview = '';
          console.log('未找到照片URL');
        }
      } catch (error) {
        console.error('加载照片失败:', error);
        this.formData.photoUrl = '';
        this.formData._photoPreview = '';
      }
    },

    // 修改 loadTableData 方法，添加照片相关处理
    loadTableData(data) {
      // 将后端字段名转换为前端字段名
      const mappedData = {
        name: data.name,
        gender: data.gender,
        ethnicity: data.ethnicity,
        birthDate: data.birthDate,
        idCard: data.idCard,
        nativePlace: data.nativePlace,
        politicalStatus: data.politicalStatus,
        healthStatus: data.healthStatus,
        education: data.education,
        graduateSchool: data.graduateSchool,
        workUnit: data.workUnit,
        job: data.job,
        title: data.title,
        isPublicOfficial: data.isPublicOfficial === 1,
        phone: data.phone,
        email: data.email,
        bankName: data.bankName,
        bankAccount: data.bankAccount,
        primaryMajor: data.primaryMajor || '',
        secondMajor: data.secondMajor || '',
        thirdMajor: data.thirdMajor || '',
        fourthMajor: data.fourthMajor || '',
        fifthMajor: data.fifthMajor || '',
        workTime: data.workTime || 0,
        isAcademic: Boolean(data.isAcademic),
        isDesignMaster: Boolean(data.isDesignMaster),
        isSubsidy: Boolean(data.isSubsidy),
        isSpecial: Boolean(data.isSpecial),
        registeredQualification: data.registeredQualification || '无',
        auditStatus: data.auditStatus || '',
        auditOpinion: data.auditOpinion || '',
        changeCounts: data.changeCounts || 0,
        joinMeeting: data.joinMeeting || 0,
        photoUrl: data.photoUrl || ''  // 添加 photoUrl 字段映射
      };
      
      // 更新表单数据，但保留现有的 photoUrl（如果存在的话）
      const currentPhotoUrl = this.formData.photoUrl;
      this.formData = {
        ...this.formData,
        ...mappedData,
        photoUrl: currentPhotoUrl || mappedData.photoUrl // 优先使用现有的 photoUrl
      };
    },
  },
  filters: {
    // 日期格式化
    formatDate(value) {
      if (!value) return '';
      return new Date(value).toLocaleDateString('zh-CN');
    }
  }
}
</script>

<style lang='scss' scoped>
.container {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background-color: #f0f2f5;
  color: #2c3e50;
}

.content-wrapper {
  flex: 1;
  padding: 24px;
  max-width: 100%;
  margin: 0 auto;
  width: 100%;
}

.status-bar {
  background: linear-gradient(135deg, #ffffff 0%, #f8f9fa 100%);
  padding: 20px 24px;
  border-radius: 12px;
  margin-bottom: 24px;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.08);
  display: flex;
  justify-content: space-between;
  align-items: center;
  border: 1px solid rgba(255, 255, 255, 0.8);
}

.current-status {
  font-size: 16px;
  color: #1a1a1a;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 8px;
  
  i {
    font-size: 20px;
    color: #1890ff;
  }
}

.loading-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(255, 255, 255, 0.9);
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  z-index: 9999;

  i {
    font-size: 32px;
    color: #1890ff;
    margin-bottom: 16px;
  }

  span {
    font-size: 16px;
    color: #1a1a1a;
  }
}

.form-container {
  background: #ffffff;
  border-radius: 12px;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.08);
  margin-bottom: 24px;
  overflow: hidden;
}

/* 标签页样式优化 */
.el-tabs {
  .el-tabs__header {
    margin: 0;
    padding: 0 24px;
    background: linear-gradient(135deg, #ffffff 0%, #f8f9fa 100%);
    border-bottom: 1px solid #e8e8e8;
  }

  .el-tabs__nav-wrap::after {
    display: none;
  }

  .el-tabs__item {
    height: 56px;
    line-height: 56px;
    font-size: 15px;
    color: #666;
    transition: all 0.3s;

    &:hover {
      color: #1890ff;
    }

    &.is-active {
      color: #1890ff;
      font-weight: 500;
    }
  }

  .el-tabs__active-bar {
    height: 3px;
    border-radius: 3px;
    background: linear-gradient(90deg, #1890ff 0%, #69c0ff 100%);
  }
}

/* 表单区域样式优化 */
.form-section {
  padding: 32px;
  border-bottom: 1px solid #f0f0f0;

  &:last-child {
    border-bottom: none;
  }

  .section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    
    h2 {
      margin: 0;
    }
    
    .header-actions {
      display: flex;
      gap: 10px;
    }
  }
}

/* 个人信息布局优化 */
.personal-info-container {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 32px;
  align-items: start;
}

.photo-section {
  width: 200px;
  position: sticky;
  top: 24px;
}

.photo-container {
  background: #f8f9fa;
  border-radius: 12px;
  padding: 16px;
  text-align: center;
  border: 1px solid #e8e8e8;
  transition: all 0.3s;

  &:hover {
    border-color: #1890ff;
    box-shadow: 0 2px 12px rgba(24, 144, 255, 0.1);
  }
}

.photo-preview {
  width: 160px;
  height: 200px;
  margin: 0 auto 16px;
  border-radius: 8px;
  overflow: hidden;
  border: 2px solid #e8e8e8;
  position: relative;

  img {
    width: 100%;
    height: 100%;
    object-fit: cover;
  }

  .photo-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    opacity: 0;
    transition: all 0.3s;
    color: white;

    &:hover {
      opacity: 1;
    }

    i {
      font-size: 24px;
      margin-bottom: 8px;
    }
  }
}

/* 表单字段布局优化 */
.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 24px;
}

.form-group {
  position: relative;

  label {
    display: block;
    font-size: 14px;
    color: #606266;
    margin-bottom: 8px;
    font-weight: 500;

    &.required::after {
      content: '*';
      color: #f56c6c;
      margin-left: 4px;
    }
  }

  .readonly-value {
    padding: 12px 16px;
    background: #f8f9fa;
    border-radius: 8px;
    border: 1px solid #e8e8e8;
    min-height: 40px;
    color: #1a1a1a;
    font-size: 14px;
  }

  .editable-value {
    input,
    select,
    textarea {
      width: 100%;
      padding: 12px 16px;
      border: 1px solid #e8e8e8;
      border-radius: 8px;
      transition: all 0.3s;
      font-size: 14px;
      color: #1a1a1a;
      background: #ffffff;

      &:hover {
        border-color: #1890ff;
      }

      &:focus {
        border-color: #1890ff;
        box-shadow: 0 0 0 2px rgba(24, 144, 255, 0.1);
        outline: none;
      }
    }
  }
}

/* 工作履历表格样式优化 */
.el-table {
  border-radius: 8px;
  overflow: hidden;
  margin-bottom: 24px;

  &::before {
    display: none;
  }

  th {
    background: #f8f9fa !important;
    font-weight: 600;
    color: #1a1a1a;
    padding: 16px !important;
  }

  td {
    padding: 16px !important;
  }
}

/* 附件上传区域样式优化 */
.attachments-container {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 24px;
}

.attachment-item {
  background: #ffffff;
  border-radius: 12px;
  padding: 20px;
  border: 1px solid #e8e8e8;
  transition: all 0.3s;

  &:hover {
    border-color: #1890ff;
    box-shadow: 0 2px 12px rgba(24, 144, 255, 0.1);
  }
}

.attachment-card {
  display: flex;
  align-items: center;
  padding: 16px;
  background: #f8f9fa;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.3s;

  &:hover {
    background: #e6f7ff;
    
    .attachment-action {
      color: #1890ff;
    }
  }

  .attachment-icon {
    font-size: 24px;
    color: #1890ff;
    margin-right: 16px;
  }

  .attachment-info {
    flex: 1;
    
    .attachment-name {
      font-size: 15px;
      color: #333;
      margin-bottom: 6px;
      display: block;
      font-weight: 500;
    }

    .attachment-action {
      font-size: 14px;
      color: #666;
      display: flex;
      align-items: center;
      gap: 4px;
      transition: all 0.3s;

      i {
        font-size: 14px;
      }
    }

    .attachment-actions {
      display: flex;
      gap: 16px;
      margin-top: 8px;

      .action-download, .action-delete {
        display: flex;
        align-items: center;
        gap: 4px;
        font-size: 14px;
        cursor: pointer;
        transition: all 0.3s;

        i {
          font-size: 14px;
        }
      }

      .action-download {
        color: #1890ff;
        
        &:hover {
          color: #40a9ff;
        }
      }

      .action-delete {
        color: #ff4d4f;
        
        &:hover {
          color: #ff7875;
        }
      }
    }
  }
}

.attachment-empty {
  padding: 16px;
  background: #f8f9fa;
  border-radius: 8px;
  display: flex;
  align-items: center;
  gap: 12px;
  color: #999;
  font-size: 14px;

  i {
    font-size: 20px;
  }
}

/* 预览对话框样式优化 */
.preview-dialog {
  .el-dialog__header {
    padding: 20px 24px;
    border-bottom: 1px solid #e8e8e8;
  }

  .el-dialog__body {
    padding: 24px;
  }

  .preview-container {
    background: #f8f9fa;
    border-radius: 8px;
    overflow: hidden;
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 400px;
  }
}

/* 响应式布局调整 */
@media (max-width: 768px) {
  .content-wrapper {
    padding: 16px;
  }

  .personal-info-container {
    grid-template-columns: 1fr;
  }

  .photo-section {
    width: 100%;
    position: static;
  }

  .form-grid {
    grid-template-columns: 1fr;
  }

  .attachments-container {
    grid-template-columns: 1fr;
  }
}

/* 搜索表单样式优化 */
.search-form {
  background: #ffffff;
  padding: 24px;
  border-radius: 12px;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.08);
  margin-bottom: 24px;

  .el-form {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 20px;
    align-items: flex-start;

    @media (max-width: 768px) {
      grid-template-columns: 1fr;
    }
  }

  .el-form-item {
    margin-bottom: 0;
    
    &.search-actions {
      display: flex;
      justify-content: flex-end;
      gap: 12px;
      grid-column: 1 / -1;
      margin-top: 8px;
    }
  }

  .el-form-item__label {
    font-size: 14px;
    color: #606266;
    padding-right: 12px;
    line-height: 40px;
    font-weight: 500;
  }

  .el-input__inner,
  .el-select .el-input__inner,
  .el-cascader .el-input__inner {
    height: 40px;
    line-height: 40px;
    border-radius: 8px;
    border: 1px solid #dcdfe6;
    transition: all 0.3s;
    font-size: 14px;
    color: #606266;
    background: #f5f7fa;

    &:hover {
      border-color: #c0c4cc;
    }

    &:focus {
      border-color: #409eff;
      background: #ffffff;
    }
  }

  .el-select,
  .el-cascader {
    width: 100%;
  }

  .el-button {
    height: 40px;
    padding: 0 20px;
    font-size: 14px;
    border-radius: 8px;
    transition: all 0.3s;

    &.el-button--primary {
      background: linear-gradient(135deg, #409eff 0%, #3a8ee6 100%);
      border: none;
      box-shadow: 0 2px 6px rgba(64, 158, 255, 0.2);

      &:hover {
        transform: translateY(-1px);
        box-shadow: 0 4px 12px rgba(64, 158, 255, 0.3);
      }

      &:active {
        transform: translateY(0);
      }
    }

    &.el-button--default {
      border: 1px solid #dcdfe6;
      color: #606266;
      background: #ffffff;

      &:hover {
        color: #409eff;
        border-color: #c6e2ff;
        background: #ecf5ff;
      }
    }
  }

  .age-range {
    display: flex;
    align-items: center;
    gap: 8px;

    .el-input {
      width: calc(50% - 16px);
    }

    .separator {
      color: #909399;
      font-size: 14px;
    }
  }
}

/* 表格样式优化 */
.el-table {
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.08);
  margin-bottom: 24px;

  &::before {
    display: none;
  }

  th {
    background: #f5f7fa !important;
    padding: 16px !important;
    font-weight: 600;
    color: #606266;
    border-bottom: 1px solid #ebeef5;
  }

  td {
    padding: 16px !important;
    color: #606266;
  }

  .el-table__row {
    transition: all 0.3s;

    &:hover > td {
      background-color: #f5f7fa !important;
    }
  }

  .el-button--text {
    padding: 0 8px;
    font-size: 14px;
    
    &:hover {
      color: #409eff;
      background: #ecf5ff;
      border-radius: 4px;
    }
  }
}

/* 标签样式优化 */
.el-tag {
  border-radius: 4px;
  padding: 0 8px;
  height: 24px;
  line-height: 22px;
  font-size: 12px;

  &.el-tag--success {
    background: #f0f9eb;
    border-color: #e1f3d8;
    color: #67c23a;
  }

  &.el-tag--warning {
    background: #fdf6ec;
    border-color: #faecd8;
    color: #e6a23c;
  }

  &.el-tag--danger {
    background: #fef0f0;
    border-color: #fde2e2;
    color: #f56c6c;
  }

  &.el-tag--info {
    background: #f4f4f5;
    border-color: #e9e9eb;
    color: #909399;
  }
}

/* 分页样式优化 */
.el-pagination {
  padding: 24px 0;
  text-align: center;

  .btn-prev,
  .btn-next {
    border-radius: 4px;
    padding: 0 8px;
    min-width: 32px;
  }

  .el-pager li {
    border-radius: 4px;
    min-width: 32px;

    &.active {
      background: #409eff;
      color: #ffffff;
    }

    &:hover {
      color: #409eff;
    }
  }

  .el-pagination__sizes {
    margin-right: 16px;
  }
}

/* 空状态样式优化 */
.empty-tip {
  padding: 48px 0;
  text-align: center;
  background: #ffffff;
  border-radius: 12px;
  margin-bottom: 24px;
  color: #909399;

  i {
    font-size: 48px;
    margin-bottom: 16px;
    color: #dcdfe6;
  }

  span {
    font-size: 14px;
  }
}

/* 加载状态样式优化 */
.loading-overlay {
  background: rgba(255, 255, 255, 0.8);
  backdrop-filter: blur(4px);

  .loading-spinner {
    font-size: 32px;
    color: #409eff;
    animation: rotate 1s linear infinite;
  }

  .loading-text {
    margin-top: 16px;
    font-size: 14px;
    color: #606266;
  }
}

@keyframes rotate {
  from {
    transform: rotate(0deg);
  }
  to {
    transform: rotate(360deg);
  }
}

/* 工作经历表格样式 */
.form-section {
  #work-experience {
    .el-table {
      margin: 0;
      border-radius: 4px;
      overflow: hidden;

      &::before {
        display: none;
      }

      .el-table__header-wrapper {
        th {
          background-color: #f5f7fa !important;
          color: #606266;
          font-weight: 600;
          padding: 8px 0;
        }
      }

      .el-table__body-wrapper {
        td {
          padding: 8px;
        }
      }

      .work-unit {
        display: inline-block;
        max-width: 100%;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
      }
    }
  }
}

/* 表格hover效果 */
.el-table__body tr:hover > td {
  background-color: #f5f7fa !important;
}

/* 表格单元格内容垂直居中 */
.el-table td, .el-table th {
  vertical-align: middle;
}

/* 表格边框颜色 */
.el-table--border, .el-table--group {
  border: 1px solid #ebeef5;
}

.el-table td, .el-table th.is-leaf {
  border-bottom: 1px solid #ebeef5;
}

.el-table--border td, .el-table--border th {
  border-right: 1px solid #ebeef5;
}

/* 表格内容字体大小和颜色 */
.el-table {
  font-size: 14px;
  color: #606266;
}

/* 表格头部样式 */
.el-table th {
  background-color: #f5f7fa;
  color: #606266;
  font-weight: 600;
  padding: 8px 0;
}

/* 表格单元格样式 */
.el-table td {
  padding: 8px;
}

/* 表格hover时的样式 */
.el-table--enable-row-hover .el-table__body tr:hover > td {
  background-color: #f5f7fa;
}

/* 其他信息样式 */
.form-section {
  padding: 20px;
  background: #fff;
  border-radius: 4px;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.05);

  .form-group {
    margin-bottom: 20px;

    label {
      display: block;
      font-size: 14px;
      color: #606266;
      margin-bottom: 10px;
      font-weight: 500;
    }

    .other-info-textarea {
      width: 100%;
      
      ::v-deep .el-textarea__inner {
        padding: 12px;
        font-size: 14px;
        line-height: 1.8;
        color: #606266;
        background-color: #f5f7fa;
        border: 1px solid #e4e7ed;
        border-radius: 4px;

        &:disabled {
          background-color: #f5f7fa;
          border-color: #e4e7ed;
          color: #606266;
          cursor: not-allowed;
        }

        &::placeholder {
          color: #c0c4cc;
        }
      }
    }
  }

  .info-meta {
    margin-top: 16px;
    padding-top: 16px;
    border-top: 1px solid #ebeef5;
    display: flex;
    gap: 24px;
    color: #909399;
    font-size: 13px;

    .meta-item {
      display: flex;
      align-items: center;
      gap: 4px;

      i {
        font-size: 14px;
      }
    }
  }
}

/* 加载状态样式 */
.el-loading-mask {
  background-color: rgba(255, 255, 255, 0.8);
  border-radius: 4px;
}

.el-loading-spinner {
  .el-loading-text {
    color: #409eff;
    font-size: 14px;
    margin: 3px 0;
  }

  .circular {
    width: 30px;
    height: 30px;
  }
}

/* 其他信息表单样式 */
/* .other-info-form {
  margin-top: 20px;
  padding: 20px;
  background-color: #fff;
  border-radius: 4px;
  box-shadow: 0 2px 12px 0 rgba(0,0,0,0.1);

  .el-textarea__inner {
    font-size: 14px;
    line-height: 1.5;
  }

  &.is-disabled {
    .el-textarea__inner {
      background-color: #f5f7fa;
      border-color: #e4e7ed;
      color: #606266;
      cursor: not-allowed;
    }
  }
} */

.upload-section {
  margin-top: 20px;
  padding: 20px;
  border: 1px solid #dcdfe6;
  border-radius: 4px;
}

.upload-item {
  margin-bottom: 10px;
}

.file-name {
  margin-top: 5px;
  font-size: 12px;
  color: #606266;
}

.upload-actions {
  text-align: center;
}

</style>


